#include <bits.h>
Classes | |
struct | Bitref |
References a single bit, returned by operator[]. More... | |
Public Member Functions | |
Bits () | |
Construct an empty bit vector. More... | |
Bits (const Bits &bits) | |
Copy constructor. More... | |
Bits (size_t n) | |
Construct a bit vector and set n'th bit. More... | |
Bits (size_t n1, size_t n2) | |
Construct a bit vector and set a range of bits n1'th to n2'th. More... | |
~Bits () | |
Destroy bits. More... | |
Bits & | operator= (const Bits &bits) |
Bitref | operator[] (size_t n) |
bool | operator[] (size_t n) const |
< n'th bit More... | |
Bits & | insert (size_t n) |
Bits & | erase (size_t n) |
Bits & | flip (size_t n) |
Bits & | insert (size_t n1, size_t n2) |
Bits & | erase (size_t n1, size_t n2) |
Bits & | flip (size_t n1, size_t n2) |
Bits & | operator|= (const Bits &bits) |
Bits & | operator&= (const Bits &bits) |
Bits & | operator^= (const Bits &bits) |
Bits & | operator-= (const Bits &bits) |
Bits | operator| (const Bits &bits) const |
< bits More... | |
Bits | operator& (const Bits &bits) const |
< bits More... | |
Bits | operator^ (const Bits &bits) const |
< bits More... | |
Bits | operator- (const Bits &bits) const |
< bits More... | |
Bits | operator~ () const |
bool | operator== (const Bits &bits) const |
< rhs bits More... | |
bool | operator!= (const Bits &bits) const |
< rhs bits More... | |
bool | operator< (const Bits &bits) const |
< rhs bits More... | |
bool | operator> (const Bits &bits) const |
< rhs bits More... | |
bool | operator<= (const Bits &bits) const |
< rhs bits More... | |
bool | operator>= (const Bits &bits) const |
< rhs bits More... | |
bool | all () const |
bool | any () const |
Bits & | clear () |
Bits & | flip () |
Bits & | reserve (size_t len) |
size_t | size () const |
size_t | count () const |
bool | intersects (const Bits &bits) const |
< bits More... | |
bool | contains (const Bits &bits) const |
< bits More... | |
size_t | find_first (size_t n=0) const |
< internal parameter (do not use) More... | |
size_t | find_next (size_t n) const |
< the current position to search from More... | |
void | swap (Bits &bits) |
Swap bit vectors. More... | |
Static Public Attributes | |
static const size_t | npos = static_cast<size_t>(-1) |
Private Member Functions | |
void | alloc (size_t len) |
On-demand allocator. More... | |
Private Attributes | |
size_t | len_ |
number of words More... | |
uint64_t * | vec_ |
array of words More... | |
RE/flex Bits class.
Dynamic bit vectors are stored in Bits objects, which can be manipulated with the usual bit-operations (|
(bitor), &
(bitand), ^
(bitxor)).
Example:
Output:
upper and lower are disjoint digit is a subset of alnum _ is not in alnum _ is in updated alnum 63 bits in alnum 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
|
inline |
Construct an empty bit vector.
|
inline |
Copy constructor.
bits | bits to copy |
|
inline |
Construct a bit vector and set n'th bit.
n | n'th bit to set |
|
inline |
Construct a bit vector and set a range of bits n1'th to n2'th.
n1 | first bit to set |
n2 | last bit to set |
|
inline |
Destroy bits.
|
inline |
Returns true if all bits are set.
|
inlineprivate |
On-demand allocator.
len | number of words required |
|
inline |
Returns true if any bit is set.
|
inline |
Erase all bits.
|
inline |
< bits
Returns true if the given bits are a subset of the bit vector, i.e. for each bit in bits, the corresponding bit in the bit vector is set.
|
inline |
Returns the number of bits set.
|
inline |
Erase a bit in the bit vector.
n | n'th bit to erase |
|
inline |
Erase a range of bits in the bit vector.
n1 | first bit to erase |
n2 | last bit to erase |
|
inline |
< internal parameter (do not use)
Returns the position of the first bit set in the bit vector, or Bits::npos if none.
|
inline |
< the current position to search from
Returns the next position of a bit set in the bit vector, or Bits::npos if none.
|
inline |
Flips a bit in the bit vector.
n | n'th bit to flip |
|
inline |
Flip a range of bits in the bit vector.
n1 | first bit to flip |
n2 | last bit to flip |
|
inline |
Flip all bits.
|
inline |
Insert and set a bit in the bit vector.
n | n'th bit to set |
|
inline |
Insert and set a range of bits in the bit vector.
n1 | first bit to set |
n2 | last bit to set |
|
inline |
< bits
Returns true if the bit vector intersects with the given bits, false if the bit vectors are disjoint.
|
inline |
< rhs bits
Returns true if bit vectors are unequal.
< bits
Bit-and (set intersection) of two bit vectors.
Bit-and (set intersection) the bit vector with the given bits.
bits | bits |
< bits
Bit-delete (set minus) of two bit vectors.
Bit-delete (set minus) the bit vector with the given bits.
bits | bits |
|
inline |
< rhs bits
Returns true if the bit vector is lexicographically less than the given right-hand side bits.
|
inline |
< rhs bits
Returns true if the bit vector is lexicographically less-or-equal to the given right-hand side bits.
Assign bits.
bits | bits to copy |
|
inline |
< rhs bits
Returns true if bit vectors are equal.
|
inline |
< rhs bits
Returns true if the bit vector is lexicographically greater than the given right-hand side bits.
|
inline |
< rhs bits
Returns true if the bit vector is lexicographically greater-or-equal to the given right-hand side bits.
|
inline |
Reference n'th bit in the bit vector to assign a value to that bit.
n | n'th bit |
|
inline |
< n'th bit
Returns n'th bit.
< bits
Bit-xor of two bit vectors.
Bit-xor the bit vector with the given bits.
bits | bits |
< bits
Bit-or (set union) of two bit vectors.
Bit-or (set union) the bit vector with the given bits.
bits | bits |
|
inline |
Complement of the bit vector with all bits flipped.
|
inline |
Reserves space in the bit vector for len bits without changing its current content.
len | number of bits to reserve |
|
inline |
Returns the current length of the bit vector.
|
inline |
Swap bit vectors.
bits | bits |
|
private |
number of words
|
static |
npos returned by find_first() and find_next()
|
private |
array of words