netgen/libsrc/general/bitarray.cpp
Matthias Hochsteger 579e5d3874 Remove BitArrayChar
2019-08-28 13:49:11 +02:00

86 lines
1.5 KiB
C++

/**************************************************************************/
/* File: bitarray.cc */
/* Autho: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
data type BitArray
*/
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
BitArray :: BitArray ()
{
size = 0;
data = NULL;
}
BitArray :: BitArray (int asize)
{
size = 0;
data = NULL;
SetSize (asize);
}
BitArray :: ~BitArray ()
{
delete [] data;
}
void BitArray :: SetSize (int asize)
{
if (size == asize) return;
delete [] data;
size = asize;
data = new unsigned char [Addr (size)+1];
}
void BitArray :: Set ()
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] = UCHAR_MAX;
}
void BitArray :: Clear ()
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] = 0;
}
void BitArray :: Invert ()
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] ^= 255;
}
void BitArray :: And (const BitArray & ba2)
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] &= ba2.data[i];
}
void BitArray :: Or (const BitArray & ba2)
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] |= ba2.data[i];
}
}