Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/util/BitVector.h>
Classes | |
class | Iter |
class | OneIterator |
class | Ref |
class | ZeroIterator |
This class provides facilities for managing vector of bits in an optimized way.
Notice that vector is represented as a contiguous block of memory. This bit vector representation is clearly not performant for sparse vectors.
Build a bit vector of the given size.
size | Count of bits in the vector. |
set | Initial value of bits (default to 0). |
References BitVector::set(), and BitVector::size().
Build a vector by copying the given one.
vec | Vector to copy. |
Build a vector by extending or reducing the given one.
vec | Vector to extend or to reduce. |
new_size | Size of the built vector. |
Apply the AND-operation on this vector with given one.
vec | Vector to process with. |
Referenced by BitVector::operator&=().
Apply the OR-operation on this vector with given one.
vec | Vector to process with. |
Referenced by BitVector::operator+=(), and BitVector::operator|=().
Apply the RESET-operation (current & ~vec) on this vector with given one.
vec | Vector to process with. |
Referenced by BitVector::operator-=().
|
inline |
|
inline |
Get the value of a bit. It is an error to pass index higher than vector size.
index | Bit index. |
Referenced by BitVector::Ref::get(), BitVector::Iter::item(), AbstractBlockAllocatorWithGC::mark(), BitVector::OneIterator::next(), BitVector::ZeroIterator::next(), BitVector::operator[](), and BitVector::print().
|
inline |
Set a bit to false.
index | Index of the bit to set. It must be higher or equal to vector size. |
Referenced by BitVector::Ref::clear().
Set to false all bits in the vector.
Referenced by BitVector::set().
Copy the giuven vector in the current vector.
vec | Vector to copy from. |
Referenced by BitVector::operator=().
int countBits | ( | void | ) | const |
Count the number of bits whose value is 1.
References elm::ones().
Referenced by BitVector::countZeroes().
int countOnes | ( | void | ) | const |
Count the number of ones in the vector.
References elm::ones().
Referenced by BitVector::countZeroes().
|
inline |
Count the number of zeroes in the vector.
References BitVector::countBits(), and BitVector::countOnes().
|
inline |
References BitVector::size().
Test if two vectors are equals.
vec | Second vector to test with. |
Referenced by BitVector::operator!=(), and BitVector::operator==().
Test if the current vector includes the given one.
vec | Vector to use. |
Referenced by BitVector::operator<=(), and BitVector::operator>=().
Test if the current vector includes strictly the given one.
vec | Vector to use. |
Referenced by BitVector::operator<(), and BitVector::operator>().
Test if the vector is empty.
Referenced by BitVector::operator bool().
Build a new vector as the result of operation AND on the current vector and the given one.
vec | Second vector of operation. |
Referenced by BitVector::operator&().
Build a new vector as the result of operation NOT of the current vector.
Referenced by BitVector::operator~().
Build a new vector as the result of operation OR on the current vector and the given one.
vec | Second vector of operation. |
Referenced by BitVector::operator+(), and BitVector::operator|().
Build a new vector as the result of operation RESET on the current vector and the given one.
vec | Second vector of operation. |
Referenced by BitVector::operator-().
Test if vectors have some bit to 1 in common.
bv | Bit vector to compare with. |
References elm::min().
Same as NOT isEmpty().
References BitVector::isEmpty().
Same as NOT equals().
References BitVector::equals().
Same as makeAnd().
References BitVector::makeAnd().
Same as applyAnd().
References BitVector::applyAnd().
Same makeOr().
References BitVector::makeOr().
Same as applyOr().
References BitVector::applyOr().
Same as makeReset().
References BitVector::makeReset().
Same makeReset().
References BitVector::applyReset().
Same as includesStrictly().
References BitVector::includesStrictly().
Same as includes().
References BitVector::includes().
Same as copy().
References BitVector::copy().
Same as equals().
References BitVector::equals().
Reverse form of includesStricly().
References BitVector::includesStrictly().
Reverse form of includes().
References BitVector::includes().
|
inline |
|
inline |
Same as bit().
References BitVector::bit().
Same as makeOr().
References BitVector::makeOr().
Same as applyOr().
References BitVector::applyOr().
Same as makeNot().
References BitVector::makeNot().
void print | ( | io::Output & | out | ) | const |
Print the bit vector in a binary form.
out | Output to use. |
References BitVector::bit(), and BitVector::size().
Referenced by elm::operator<<().
void resize | ( | int | new_size | ) |
Resize the vector.
new_size | New size (in bits). |
References elm::array::copy(), and elm::min().
|
inline |
Set to true a bit.
index | Index of the bit to set. It must be higher or equal to vector size. |
Referenced by AbstractBlockAllocatorWithGC::mark(), and BitVector::Ref::set().
Set the value of a bit.
index | Index of the bit to set. It must be higher or equal to vector size. |
value | Value of the bit. |
References BitVector::clear(), and BitVector::set().
Referenced by BitVector::BitVector(), and BitVector::set().
|
inline |
Get the size in bits of the vector.
Referenced by BitVector::BitVector(), BitVector::end(), BitVector::Iter::ended(), BitVector::OneIterator::next(), BitVector::ZeroIterator::next(), and BitVector::print().