BALL
1.4.79
|
#include <BALL/DATATYPE/bitVector.h>
Public Member Functions | |
Constructors and Destructors | |
BitVector () | |
BitVector (Size size) | |
BitVector (const BitVector &bit_vector) | |
BitVector (const char *bit_string) | |
virtual | ~BitVector () |
void | clear () |
Assignment | |
void | set (const BitVector &bit_vector) |
void | set (const char *bit_string) |
BitVector & | operator= (const BitVector &bit_vector) |
BitVector & | operator= (const char *bit_string) |
void | get (BitVector &bitvector) const |
Accessors | |
BitVector | operator() (Index first, Index last) const |
void | setSize (Size size, bool keep=true) |
Size | getSize () const |
Size | countValue (bool value) const |
VectorType & | getBitSet () |
const VectorType & | getBitSet () const |
Bit | operator[] (Index index) |
bool | operator[] (Index index) const |
void | setBit (Index index, bool value=true) |
bool | getBit (Index index) |
bool | getBit (Index index) const |
void | toggleBit (Index index) |
void | fill (bool value=true, Index first=0, Index last=-1) |
void | toggle (Index first=0, Index last=-1) |
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) |
void | bitwiseXor (const BitVector &bit_vector) |
void | bitwiseAnd (const BitVector &bit_vector) |
BitVector | operator| (const BitVector &bit_vector) |
BitVector & | operator|= (const BitVector &bit_vector) |
BitVector | operator& (const BitVector &bit_vector) |
BitVector & | operator&= (const BitVector &bit_vector) |
BitVector | operator^ (const BitVector &bit_vector) |
BitVector & | operator^= (const BitVector &bit_vector) |
BitVector | operator~ () |
Predicates | |
bool | operator== (const BitVector &bit_vector) const |
Equality operator. More... | |
bool | operator!= (const BitVector &bit_vector) const |
Inequality operator. More... | |
bool | isAnyBit (bool value, Index first=0, Index last=-1) const |
bool | isEveryBit (bool value, Index first=0, Index last=-1) const |
Debugging and Diagnostics | |
bool | isValid () const |
Protected Member Functions | |
void | validateIndex_ (Index &index) |
void | validateIndex_ (Index &index) const |
void | validateRange_ (Index &first, Index &last) const |
Type Definitions and Constants | |
typedef unsigned char | BlockType |
typedef std::vector< BlockType > | VectorType |
static const Size | BlockSize |
Storers | |
virtual void | read (std::istream &s) |
virtual void | write (std::ostream &s) const |
virtual void | write (PersistenceManager &pm) const |
virtual bool | read (PersistenceManager &pm) |
BALL_EXPORT friend std::istream & | operator>> (std::istream &s, BitVector &bit_vector) |
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 176 of file bitVector.h.
typedef unsigned char BALL::BitVector::BlockType |
Definition at line 188 of file bitVector.h.
typedef std::vector<BlockType> BALL::BitVector::VectorType |
Definition at line 190 of file bitVector.h.
BALL::BitVector::BitVector | ( | ) |
Default constructor
BALL::BitVector::BitVector | ( | Size | size | ) |
Detailed constructor
Exception::OutOfMemory | if a BitVector with length size could not be allocated |
BALL::BitVector::BitVector | ( | const BitVector & | bit_vector | ) |
Copy constructor
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
BALL::BitVector::BitVector | ( | const char * | bit_string | ) |
Detailled constructor from an array of char. {Caveat:} the array of char has to be zero-terminated!
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
|
virtual |
Destructor
void BALL::BitVector::bitwiseAnd | ( | const BitVector & | bit_vector | ) |
Compute {this and bit_vector}. The result is saved in this instance.
Exception::OutOfMemory |
void BALL::BitVector::bitwiseOr | ( | const BitVector & | bit_vector | ) |
Compute {this or bit_vector}. The result is saved in this instance.
Exception::OutOfMemory |
void BALL::BitVector::bitwiseXor | ( | const BitVector & | bit_vector | ) |
Compute {this xor bit_vector}. The result is saved in this instance.
Exception::OutOfMemory |
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 |
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 |
Exception::IndexUnderflow | |
Exception::OutOfMemory |
void BALL::BitVector::get | ( | BitVector & | bitvector | ) | const |
Assignment to an other BitVector.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
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 |
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 |
VectorType& BALL::BitVector::getBitSet | ( | ) |
Return a muteable pointer to the values of this instance.
const VectorType& BALL::BitVector::getBitSet | ( | ) | const |
Return a constant 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.
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 |
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.
And Operator. Creates a new BitVector object and fills it with the result of {this and bit_Vector}.
Exception::OutOfMemory |
Compute {this and bit_vector}. The result is saved in this instance.
Exception::OutOfMemory |
Assignment from an other BitVector instance.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
BitVector& BALL::BitVector::operator= | ( | const char * | bit_string | ) |
Assignment from a char string. If a char is different from '0', it is interpreted as true.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
Random access to the components. If the given index is greater than the size of this instance, this BitVector is increased to the given index.
Exception::OutOfMemory | if the bit could not be allocated |
Constant random access to the components. If the given index is greater than the size of this instance an exception is thrown.
Xor Operator. Creates a new BitVector object and fills it with the result of {this Xor bit_vector}.
Exception::OutOfMemory |
Compute {this xor bit_vector}. The result is saved in this instance.
Exception::OutOfMemory |
Or Operator. Creates a new BitVector object and fills it with the result of {this or bit_Vector}.
Exception::OutOfMemory |
Compute {this or bit_vector}. The result is saved in this instance.
Exception::OutOfMemory |
BitVector BALL::BitVector::operator~ | ( | ) |
Negate Operator. Creates a new BitVector object and fills it with the negate result of this instance.
Exception::OutOfMemory |
|
virtual |
Read the values of of type bool from an istream.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
|
virtual |
Storable read method.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
void BALL::BitVector::set | ( | const BitVector & | bit_vector | ) |
Assignment from an other BitVector instance.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
void BALL::BitVector::set | ( | const char * | bit_string | ) |
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!
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
Set the size of this instance.
size | the new size |
keep | ????? |
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
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.
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 |
Exception::IndexUnderflow | |
Exception::OutOfMemory |
void BALL::BitVector::toggleBit | ( | Index | index | ) |
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 |
Exception::IndexUnderflow | |
Exception::OutOfMemory |
|
protected |
|
protected |
|
virtual |
Write the values of of type bool to an ostream.
|
virtual |
Storable write method.
|
friend |
Output operator. Writes the values of type bool to an ostream.
|
friend |
Input operator. Reads the values of type bool from an istream.
Exception::OutOfMemory | if a BitVector with the appropriate size could not be allocated |
|
static |
Definition at line 192 of file bitVector.h.