Detailed Description
- See also:
- Template Class
Tab, Class BitArrayCallback.
- Description:
- This class allows the developer to define a set of bit flags
that may be treated as a virtual array and are stored in an
efficient manner. The class has methods to set, clear and return
the i-th bit, resize the BitArray, etc. All methods are
implemented by the system.
#include <bitarray.h>
List of all
members.
Constructor & Destructor Documentation
{ bits = NULL; numBits = 0; BitArrayAllocated(); }
- Parameters:
- int i
The size of the BitArray in bits.
{
DbgAssert( n >= 0 );
if (n < 0)
{
n = 0;
}
if( UseLocalBits(n) )
{
numBits = n;
localBits = 0;
BitArrayAllocated();
}
else
{
CreateBitArrayImpl(n);
}
}
- Parameters:
- const BitArray& b
The BitArray to
duplicate.
{
if( b.UseLocalBits() )
{
localBits = b.localBits;
numBits = b.numBits;
BitArrayAllocated();
}
else
{
SetBitsFromImpl(b);
}
}
{
if( !UseLocalBits() )
FreeBitsImpl();
else
BitArrayDeallocated();
}
Member Function Documentation
GEOMEXPORT void SetSize |
( |
int |
n, |
|
|
int |
save = 0 |
|
) |
|
|
- Parameters:
-
n |
- The number of bits in to be in the array. If this value is a
negative number, or equal to the current size of the BitArray then nothing will
happen. |
save=0 |
- If passed as 1, the old bit values will be preserved when the
array is resized. |
int GetSize |
( |
|
) |
const [inline] |
void ClearAll |
( |
|
) |
[inline] |
{
UseLocalBits() ? localBits = 0 : ClearAllImpl();
}
{
UseLocalBits() ? localBits = BitMask(numBits) - 1 : SetAllImpl();
}
void Set |
( |
int |
i |
) |
[inline] |
- Parameters:
-
i |
- The array index of the bit to set. |
{
DbgAssert(i>-1 && i<numBits);
if ((i > -1) && (i < numBits))
{
UseLocalBits() ? localBits |= BitMask(i) : SetImpl(i);
}
}
void Clear |
( |
int |
i |
) |
[inline] |
- Parameters:
- int i
The array index of the bit to clear.
{
DbgAssert(i>-1 && i<numBits);
if ((i > -1) && (i < numBits))
{
UseLocalBits() ? localBits &= ~BitMask(i) : ClearImpl(i);
}
}
void Set |
( |
int |
i, |
|
|
int |
b |
|
) |
|
[inline] |
- Parameters:
-
i |
- The index of the bit to set. |
b |
- The value to set, either 1 or 0. |
int operator[] |
( |
int |
i |
) |
const [inline] |
- Parameters:
-
i |
- The index of the bit. If the index is a negative or bigger
than the array size, it returns 0 |
{
DbgAssert (i>-1);
DbgAssert (i<numBits);
if ((i > -1) && (i < numBits))
return UseLocalBits() ? (localBits & BitMask(i) ? 1 : 0) : GetNthBitImpl(i);
else
return 0;
}
bool IsEmpty |
( |
|
) |
const [inline] |
{ return UseLocalBits() ? !localBits : IsEmptyImpl(); }
bool AnyBitSet |
( |
|
) |
const [inline] |
- Returns:
- Returns a proxy object which can optimize client code depending
on the type of access required (ie: != 0 would call IsEmpty(),
etc)
GEOMEXPORT void Compress |
( |
|
) |
|
GEOMEXPORT void Expand |
( |
|
) |
|
GEOMEXPORT void Reverse |
( |
BOOL |
keepZero = FALSE |
) |
|
- Parameters:
- BOOL keepZero = FALSE
If TRUE the zero bit is kept where it is.
GEOMEXPORT void Rotate |
( |
int |
direction, |
|
|
int |
count |
|
) |
|
|
- Parameters:
- int direction
The direction to rotate.
int count
The number of bits to rotate.
GEOMEXPORT void Shift |
( |
int |
direction, |
|
|
int |
count, |
|
|
int |
where = 0 |
|
) |
|
|
- Parameters:
- int direction
One of the following values:
LEFT_BITSHIFT
RIGHT_BITSHIFT
int count
The number of bits to shift.
int where=0
This indicates where the shift will begin. For example, if you have
a BitArray
containing: 10101010
and you Shift(LEFT_BITSHIFT, 1, 4) you'll get:
10100100
All the bits from 4 to 8 are shifted one bit left, with zeroes
shifted in from the right. The first bit affected is the
where bit. If you leave off the where parameter you'd
get the usual: 01010100
The RIGHT_BITSHIFT starts at that bit; it is unaffected
because the operation proceeds to the right: 10101010.
Shift(RIGHT_BITSHIFT, 1, 4) results in:
10101101.
- Parameters:
- BitArrayCallback
&cb
The callback object whose proc() method is called.
GEOMEXPORT void DeleteSet |
( |
BitArray & |
dset, |
|
|
int |
mult = 1 |
|
) |
|
|
- Parameters:
- BitArray &
dset
This is a bit array which represents which elements should be
deleted. Typically (if mult==1) dset will have the same size as
(this).
int mult=1
This is a multiplier which indicates how many elements in (*this)
are deleted for each entry in dset. For instance, when deleting
faces in a mesh, you also need to delete the corresponding edge
selection data. Since edgeSel[f*3], edgeSel[f*3+1], and
edgeSel[f*3+2] correspond to face f, you'd use mult=3:
faceSel.DeleteSet (fdel);
edgeSel.DeleteSet (fdel, 3);
bool operator== |
( |
const BitArray & |
b |
) |
const [inline] |
- Parameters:
- const BitArray& b
The BitArray to
compare with this one.
- Returns:
- true if the BitArrays are 'equal' (same size and same bits
set); otherwise false.
{
return (numBits == b.numBits) && (UseLocalBits() ? (localBits == b.localBits) : CompareBitsImpl(b));
}
GEOMEXPORT void Swap |
( |
BitArray & |
other |
) |
|
Swap the contents of two bitarrays.
This is an efficient way of transfering the contents of a
temporary bitarray object into a more permanent instance, such as a
data member. For instance:
{
BitArray tmp(size);
m_MyBitArray.Swap(tmp);
}
would be more efficient than using operator= in this case.
- Parameters:
-
[in,out] |
other |
The contents of 'other' will be swaped with the contents of
'this' |
Friends And Related Function Documentation
Member Data Documentation
BitArray BitArray BitArray BitArray
BitArray BitArray BitArray BitArray BitArray BitArray
BitArray BitArray BitArray BitArray
BitArray BitArray BitArray BitArray BitArray BitArray