#include <BitArrayBase.h>
Inheritance diagram for BitArrayBase::

Public Methods | |
| BitArrayBase () | |
| Empty constructor. | |
| BitArrayBase (const size_type len, const size_type nbytes=0, char *d=(char *) 0, const EnumDataOwned o=DataNotOwned) | |
| Constructor that initializes the length and possibly data. More... | |
| BitArrayBase (const BitArrayBase &array) | |
| Copy constructor. | |
| virtual | ~BitArrayBase () |
| Destructor. | |
| int | shared_mem () const |
| Returns TRUE if this array shares data with another array. | |
| int | resize (const size_type num) |
| Resize the array to support num bits. | |
| size_type | size () const |
| Returns the length of the array. | |
| int | len () const |
| Returns the length of the array. This method is deprecated. | |
| char * | data () const |
| Returns the internal byte-array that contains bit information. | |
| int | nrefs () const |
| Returns the number of references to the internal array . | |
| BitArrayBase & | operator= (const BitArrayBase &array) |
| Copies the array object by constructing a new BitArrayBase. | |
| BitArrayBase & | operator &= (const BitArrayBase &array) |
| Copies the pointer from the array object and increments the data's reference counter. | |
| BitArrayBase & | operator &= (BitArrayBase &array) |
| Copies the pointer from the array object and increments the data's reference counter, updating array if it is not shared. | |
| BitArrayBase & | operator= (const int value) |
Set all elements equal to value. | |
| BitArrayBase & | operator<< (const BitArrayBase &vec) |
Copy vec into the current array. | |
| virtual void | put (const size_type ndx, const int val)=0 |
| Put bit value val in the ndx-th bit-pair. | |
| int | operator== (const BitArrayBase &array) const |
| Checks to see if the current array equals array. | |
| int | operator!= (const BitArrayBase &array) const |
| Checks to see if the current array does not equal array. | |
| int | compare (const BitArrayBase &array) const |
| Compares the current array with array. More... | |
| int | operator> (const BitArrayBase &) const |
| Perform an element-wise comparison for greater-than. | |
| int | operator>= (const BitArrayBase &) const |
| Perform an element-wise comparison for greater-than-or-equal-to. | |
| int | write (ostream &output) const |
| Write the array to an output stream. More... | |
| virtual int | read (istream &input)=0 |
| Read the array from an input stream. | |
| int | write (PackBuffer &output) const |
Pack the array into a PackBuffer class. | |
| int | read (UnPackBuffer &input) |
Unpack the array from an UnPackBuffer class. | |
Protected Methods | |
| virtual int | operator[] (const size_type ndx) const=0 |
| Returns the value of the ndx-th bit-pair. | |
| void | construct (const size_type len, const size_type nbytes, char *d, const EnumDataOwned o=DataNotOwned) |
| Method used by constructors to setup the internal array class. | |
| void | free () |
| Method used to delete the internal array class. | |
| void | set_shared_data (char *data, const size_type len_, const size_type array_len_, const EnumDataOwned o=DataNotOwned) |
| Method to explicitly set the shared data array to a pointer array. | |
| virtual int | element_size () const=0 |
| Returns the number of bits in an element in the array. | |
| void | initialize (const size_type curr_array_len, const size_type new_array_len) |
| Initialie the 'end' of an array (e.g. after resizing it). | |
Protected Attributes | |
| char * | Data |
| The pointer to this array's data. | |
| size_type | Len |
The number of bytes allocated in Data. | |
| size_type | array_len |
| The number of elements in the array. | |
| BitArrayRef * | shared |
| Pointer tothe structure that maintains the shared pointer. | |
Friends | |
| class | ArrayRef< char, BitArrayBase > |
| class | BitArrayRef |
The main elements of this array have the same look and feel as a SimpleArray object. However, this class uses a special, compact representation of the data elements, which forces it to be a separate class. This class does not impose a restriction on the maximum length of the bit array.
To minimize the memory impact of these arrays, the reference count is only used when needed. Specifically, the BitArrayRep class is used (1) when a constructor passes data that is not owned by the array or (2) after methods like operator &= and set_data are called, which initiate the use of reference counting. Thus by default the memory usage of a BitArray is two pointers, an integer counter and the memory in the array.
Note that this memory optimization requires that the class BitArrayRep know about all of the classes that have pointers to its data. This is somewhat dangerous, since you can run into cases where the many arrays are shared, at which point the sharing mechanism becomes quite cumbersome. However, these cases appear to be rare, and this code reflects the common usage of this class. The variable BitArrayRep<T>::num_refs_limit can be used to set the maximum number of references allowed in a code. When this is exceeded, this code aborts.
|
||||||||||||||||||||
|
Constructor that initializes the length and possibly data. The len parameter specifies the number of sets of bits. If the d parameter is not null, then this array is assumed to have length nbytes. The initialization of the array then depends upon the value of the o parameter. If o is DataNotOwned (the default), then the data is copied from d. Otherwise, the internal point is set to d and the internal ownership flag is set to o. |
|
|
Compares the current array with array. If the current array is longer, then returns 1. If shorter, then returns -1. Otherwise, does a pairwise comparison on elements of both arrays. If there exists a nonequal pair of elements, then returns 1 if the current array is greater and -1 otherwise. |
|
|
Write the array to an output stream. The format for this output is <len> : <bit-1><bit-2>...<bit-n> Reimplemented in EnumBitArray. |