#include <BALL/DATATYPE/bitVector.h>
Public Member Functions | |
Constructors and Destructors | |
BitVector () | |
BitVector (Size size) throw (Exception::OutOfMemory) | |
BitVector (const BitVector &bit_vector) throw (Exception::OutOfMemory) | |
BitVector (const char *bit_string) throw (Exception::OutOfMemory) | |
virtual | ~BitVector () |
void | clear () |
Assignment | |
void | set (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
Assignment from an other BitVector instance. | |
void | set (const char *bit_string) throw (Exception::OutOfMemory) |
BitVector & | operator= (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
Assignment from an other BitVector instance. | |
BitVector & | operator= (const char *bit_string) throw (Exception::OutOfMemory) |
void | get (BitVector &bitvector) const throw (Exception::OutOfMemory) |
Assignment to an other BitVector. | |
Accessors | |
BitVector | operator() (Index first, Index last) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
void | setSize (Size size, bool keep=true) throw (Exception::OutOfMemory) |
Size | getSize () const |
Size | countValue (bool value) const |
VectorType & | getBitSet () |
const VectorType & | getBitSet () const |
Bit | operator[] (Index index) throw (Exception::OutOfMemory) |
bool | operator[] (Index index) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
void | setBit (Index index, bool value=true) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
bool | getBit (Index index) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
bool | getBit (Index index) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
void | toggleBit (Index index) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
void | fill (bool value=true, Index first=0, Index last=-1) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
void | toggle (Index first=0, Index last=-1) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
void | setUnsignedChar (unsigned char bit_pattern) |
unsigned char | getUnsignedChar () const |
void | setUnsignedShort (unsigned short bit_pattern) |
unsigned short | getUnsignedShort () const |
void | setUnsignedInt (unsigned int bit_pattern) |
unsigned int | getUnsignedInt () const |
void | setUnsignedLong (unsigned long bit_pattern) |
unsigned long | getUnsignedLong () const |
void | bitwiseOr (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
void | bitwiseXor (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
void | bitwiseAnd (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector | operator| (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector & | operator|= (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector | operator& (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector & | operator&= (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector | operator^ (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector & | operator^= (const BitVector &bit_vector) throw (Exception::OutOfMemory) |
BitVector | operator~ () throw (Exception::OutOfMemory) |
Predicates | |
bool | operator== (const BitVector &bit_vector) const |
Equality operator. | |
bool | operator!= (const BitVector &bit_vector) const |
Inequality operator. | |
bool | isAnyBit (bool value, Index first=0, Index last=-1) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
bool | isEveryBit (bool value, Index first=0, Index last=-1) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
Debugging and Diagnostics | |
bool | isValid () const |
Protected Member Functions | |
void | validateIndex_ (Index &index) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
void | validateIndex_ (Index &index) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
void | validateRange_ (Index &first, Index &last) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
Private Member Functions | |
Index | block_ (Index index) throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
Index | block_ (Index index) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
BlockType | mask_ (Index index) const |
Private Attributes | |
Size | size_ |
VectorType | bitset_ |
Type Definitions and Constants | |
| |
typedef unsigned char | BlockType |
typedef std::vector< BlockType > | VectorType |
static const Size | BlockSize |
Storers | |
| |
virtual void | read (std::istream &s) throw (Exception::OutOfMemory) |
virtual void | write (std::ostream &s) const |
virtual void | write (PersistenceManager &pm) const |
virtual bool | read (PersistenceManager &pm) throw (Exception::OutOfMemory) |
BALL_EXPORT friend std::istream & | operator>> (std::istream &s, BitVector &bit_vector) throw (Exception::OutOfMemory) |
BALL_EXPORT friend std::ostream & | operator<< (std::ostream &s, const BitVector &bit_vector) |
Bit vector class. Indices may be given as negative arguments: start from the end -1 therefore means the last bit. Some functions resize the instance if a index greater than the size of the instance is given. Other functions throw exception in this case.
Definition at line 175 of file bitVector.h.
typedef unsigned char BALL::BitVector::BlockType |
Definition at line 187 of file bitVector.h.
typedef std::vector<BlockType> BALL::BitVector::VectorType |
Definition at line 189 of file bitVector.h.
BALL::BitVector::BitVector | ( | ) |
Default constructor
BALL::BitVector::BitVector | ( | Size | size | ) | throw (Exception::OutOfMemory) |
Detailled constructor
BALL::BitVector::BitVector | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Copy constructor
BALL::BitVector::BitVector | ( | const char * | bit_string | ) | throw (Exception::OutOfMemory) |
Detailled constructor from an array of char. {Caveat:} the array of char has to be zero-terminated!
virtual BALL::BitVector::~BitVector | ( | ) | [virtual] |
Destructor
void BALL::BitVector::bitwiseAnd | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Compute {this and bit_vector}. The result is saved in this instance.
void BALL::BitVector::bitwiseOr | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Compute {this or bit_vector}. The result is saved in this instance.
void BALL::BitVector::bitwiseXor | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Compute {this xor bit_vector}. The result is saved in this instance.
Index BALL::BitVector::block_ | ( | Index | index | ) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) [private] |
Index BALL::BitVector::block_ | ( | Index | index | ) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) [private] |
void BALL::BitVector::clear | ( | ) |
Clear method. This method will set the size of this instance to 0.
Count a given bool value in this instance.
value | the value to be counted |
void BALL::BitVector::fill | ( | bool | value = true , |
|
Index | first = 0 , |
|||
Index | last = -1 | |||
) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
Fill a part of this instance with a given value. If a given index is greater than the size of this instance an exception is thrown.
value | the value to be set | |
first | the starting position | |
last | the last element to be filled |
void BALL::BitVector::get | ( | BitVector & | bitvector | ) | const throw (Exception::OutOfMemory) |
Assignment to an other BitVector.
bool BALL::BitVector::getBit | ( | Index | index | ) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
Get the value of an element (const version). If the given index is greater than the size of this instance an exception is thrown. No resizing is done.
index | the index of the element |
bool BALL::BitVector::getBit | ( | Index | index | ) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
Get the value of an element. If the given index is greater than the size of this instance, this BitVector is increased to the given index.
index | the index of the element |
const VectorType& BALL::BitVector::getBitSet | ( | ) | const |
Return a constant pointer to the values of this instance.
VectorType& BALL::BitVector::getBitSet | ( | ) |
Return a muteable pointer to the values of this instance.
Size BALL::BitVector::getSize | ( | ) | const |
Return the size of this instance.
unsigned char BALL::BitVector::getUnsignedChar | ( | ) | const |
Get the bit pattern as unsigned char. For example: 00010110 => 22.
unsigned int BALL::BitVector::getUnsignedInt | ( | ) | const |
Get the bit pattern as unsigned int.
unsigned long BALL::BitVector::getUnsignedLong | ( | ) | const |
Get the bit pattern as unsigned long.
unsigned short BALL::BitVector::getUnsignedShort | ( | ) | const |
Get the bit pattern as unsigned short.
bool BALL::BitVector::isAnyBit | ( | bool | value, | |
Index | first = 0 , |
|||
Index | last = -1 | |||
) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
Test if any bit in a given range has the given value.
value | the value to look for | |
first | the index to start searching | |
last | the index to stop searching |
bool BALL::BitVector::isEveryBit | ( | bool | value, | |
Index | first = 0 , |
|||
Index | last = -1 | |||
) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
Test if every bit in a given range has the given value
value | the value to look for | |
first | the index to start searching | |
last | the index to stop searching |
bool BALL::BitVector::isValid | ( | ) | const |
Test if this instance is valid.
BitVector BALL::BitVector::operator& | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
And Operator. Creates a new BitVector object and fills it with the result of {this and bit_Vector}.
BitVector& BALL::BitVector::operator&= | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Compute {this and bit_vector}. The result is saved in this instance.
BitVector BALL::BitVector::operator() | ( | Index | first, | |
Index | last | |||
) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
BitVector& BALL::BitVector::operator= | ( | const char * | bit_string | ) | throw (Exception::OutOfMemory) |
Assignment from a char string. If a char is different from '0', it is interpreted as true.
BitVector& BALL::BitVector::operator= | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Assignment from an other BitVector instance.
bool BALL::BitVector::operator[] | ( | Index | index | ) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) |
Constant random access to the components. If the given index is greater than the size of this instance an exception is thrown.
Bit BALL::BitVector::operator[] | ( | Index | index | ) | throw (Exception::OutOfMemory) |
BitVector BALL::BitVector::operator^ | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Xor Operator. Creates a new BitVector object and fills it with the result of {this Xor bit_vector}.
BitVector& BALL::BitVector::operator^= | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Compute {this xor bit_vector}. The result is saved in this instance.
BitVector BALL::BitVector::operator| | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Or Operator. Creates a new BitVector object and fills it with the result of {this or bit_Vector}.
BitVector& BALL::BitVector::operator|= | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Compute {this or bit_vector}. The result is saved in this instance.
BitVector BALL::BitVector::operator~ | ( | ) | throw (Exception::OutOfMemory) |
Negate Operator. Creates a new BitVector object and fills it with the negate result of this instance.
virtual bool BALL::BitVector::read | ( | PersistenceManager & | pm | ) | throw (Exception::OutOfMemory) [virtual] |
Storable read method.
virtual void BALL::BitVector::read | ( | std::istream & | s | ) | throw (Exception::OutOfMemory) [virtual] |
Read the values of of type bool from an istream.
void BALL::BitVector::set | ( | const char * | bit_string | ) | throw (Exception::OutOfMemory) |
Assignment from a char string. If a char is different from '0', it is interpreted as true. {Caveat:} the array of char has to be zero-terminated!
void BALL::BitVector::set | ( | const BitVector & | bit_vector | ) | throw (Exception::OutOfMemory) |
Assignment from an other BitVector instance.
void BALL::BitVector::setBit | ( | Index | index, | |
bool | value = true | |||
) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
void BALL::BitVector::setSize | ( | Size | size, | |
bool | keep = true | |||
) | throw (Exception::OutOfMemory) |
Set the size of this instance.
size | the new size | |
keep | ????? |
void BALL::BitVector::setUnsignedChar | ( | unsigned char | bit_pattern | ) |
Set a unsigned char as the bit pattern. For example: 22 => 00010110.
bit_pattern | the new pattern. |
void BALL::BitVector::setUnsignedInt | ( | unsigned int | bit_pattern | ) |
Set a unsigned int as the bit pattern.
void BALL::BitVector::setUnsignedLong | ( | unsigned long | bit_pattern | ) |
Set a unsigned long as the bit pattern.
void BALL::BitVector::setUnsignedShort | ( | unsigned short | bit_pattern | ) |
Set a unsigned short as the bit pattern.
void BALL::BitVector::toggle | ( | Index | first = 0 , |
|
Index | last = -1 | |||
) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
Toggle the values of a part of this instance. If a given index is greater than the size of this instance an exception is thrown.
value | the value to be set | |
first | the starting position | |
last | the last element to be filled |
void BALL::BitVector::toggleBit | ( | Index | index | ) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) |
Toggle the value of an element. If the given index is greater than the size of this instance an exception is thrown.
index | the index of the element |
void BALL::BitVector::validateIndex_ | ( | Index & | index | ) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) [protected] |
void BALL::BitVector::validateIndex_ | ( | Index & | index | ) | throw (Exception::IndexUnderflow, Exception::OutOfMemory) [protected] |
void BALL::BitVector::validateRange_ | ( | Index & | first, | |
Index & | last | |||
) | const throw (Exception::IndexUnderflow, Exception::IndexOverflow) [protected] |
virtual void BALL::BitVector::write | ( | PersistenceManager & | pm | ) | const [virtual] |
Storable write method.
virtual void BALL::BitVector::write | ( | std::ostream & | s | ) | const [virtual] |
Write the values of of type bool to an ostream.
BALL_EXPORT friend std::ostream& operator<< | ( | std::ostream & | s, | |
const BitVector & | bit_vector | |||
) | [friend] |
Output operator. Writes the values of type bool to an ostream.
BALL_EXPORT friend std::istream& operator>> | ( | std::istream & | s, | |
BitVector & | bit_vector | |||
) | throw (Exception::OutOfMemory) [friend] |
Input operator. Reads the values of type bool from an istream.
VectorType BALL::BitVector::bitset_ [private] |
Definition at line 568 of file bitVector.h.
const Size BALL::BitVector::BlockSize [static] |
Definition at line 191 of file bitVector.h.
Size BALL::BitVector::size_ [private] |
Definition at line 567 of file bitVector.h.