netgen/libsrc/general/ngbitarray.cpp

86 lines
1.6 KiB
C++
Raw Normal View History

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