BitArray Class Reference

An array of binary values. More...

#include <BitArray.h>

Inheritance diagram for BitArray::

BitArrayBase List of all members.

Public Methods

 BitArray ()
 Empty constructor.

 BitArray (const size_type len, const size_type nbytes=0, char *d=(char *) 0, const EnumDataOwned o=DataNotOwned)
 Standard constructor.

 BitArray (const BitArray &array)
 Copy constructor.

int operator() (const size_type ndx) const
 Return ON/OFF value for the ndx index.

void put (const size_type ndx, const int val)
 Put value val at the ndx index.

void set (const size_type ndx)
 Set the ndx-th bit to ON.

void set ()
 Set all bits ON.

void reset (const size_type ndx)
 Set the ndx-th bit to OFF.

void reset ()
 Set all bits to OFF.

void flip (const size_type ndx)
 Flip bit value of the ndx-th bit.

void flip ()
 Flip all bits.

size_type nbits () const
 Returns the number of bits that are set ON.

int read (istream &input)
 Read the array from an input stream.

int shared_one (BitArray &other) const
 Return true (1) if the two BitArrays both have a 1 in at least one bit. More...


Protected Methods

int operator[] (const size_type ndx) const
 Return ON/OFF value for the ndx index.

int element_size () const
 Return the number of bits in an "element".


Detailed Description

An array of binary values.

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.


Member Function Documentation

int BitArray::shared_one BitArray &    other const
 

Return true (1) if the two BitArrays both have a 1 in at least one bit.

Equivalent to a bitwise AND and then comparing nbits() on the result to 0, but much more efficient (e.g. can return as soon as find agreement


The documentation for this class was generated from the following file: