libstdc++
|
Classes | |
class | reference |
Public Types | |
typedef __dynamic_bitset_base < _WordT, _Alloc > | _Base |
typedef _Alloc | allocator_type |
typedef _WordT | block_type |
typedef bool | const_reference |
typedef size_t | size_type |
Public Member Functions | |
dynamic_bitset (const allocator_type &__alloc=allocator_type()) | |
dynamic_bitset (size_type __nbits, unsigned long long __val=0ULL, const allocator_type &__alloc=allocator_type()) | |
dynamic_bitset (initializer_list< block_type > __il, const allocator_type &__alloc=allocator_type()) | |
template<typename _CharT , typename _Traits , typename _Alloc1 > | |
dynamic_bitset (const std::basic_string< _CharT, _Traits, _Alloc1 > &__str, typename basic_string< _CharT, _Traits, _Alloc1 >::size_type __pos=0, typename basic_string< _CharT, _Traits, _Alloc1 >::size_type __n=std::basic_string< _CharT, _Traits, _Alloc1 >::npos, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1'), const allocator_type &__alloc=allocator_type()) | |
dynamic_bitset (const char *__str, const allocator_type &__alloc=allocator_type()) | |
dynamic_bitset (const dynamic_bitset &__b) | |
dynamic_bitset (dynamic_bitset &&__b) | |
template<typename _CharT , typename _Traits > | |
void | _M_copy_from_ptr (const _CharT *, size_t, size_t, size_t, _CharT, _CharT) |
template<typename _CharT , typename _Traits , typename _Alloc1 > | |
void | _M_copy_from_string (const std::basic_string< _CharT, _Traits, _Alloc1 > &__str, size_t __pos, size_t __n, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1')) |
template<typename _CharT , typename _Traits , typename _Alloc1 > | |
void | _M_copy_to_string (std::basic_string< _CharT, _Traits, _Alloc1 > &__str, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1')) const |
bool | all () const |
bool | any () const |
void | append (block_type __block) |
void | append (initializer_list< block_type > __il) |
template<typename _BlockInputIterator > | |
void | append (_BlockInputIterator __first, _BlockInputIterator __last) |
void | clear () |
size_type | count () const |
bool | empty () const |
size_type | find_first () const |
size_type | find_next (size_t __prev) const |
dynamic_bitset< _WordT, _Alloc > & | flip () |
dynamic_bitset< _WordT, _Alloc > & | flip (size_type __pos) |
allocator_type | get_allocator () const |
bool | is_proper_subset_of (const dynamic_bitset &__b) const |
bool | is_subset_of (const dynamic_bitset &__b) const |
size_type | max_size () const |
bool | none () const |
size_type | num_blocks () const |
dynamic_bitset & | operator= (const dynamic_bitset &__b) |
dynamic_bitset & | operator= (dynamic_bitset &&__b) |
dynamic_bitset< _WordT, _Alloc > | operator~ () const |
void | push_back (bool __bit) |
dynamic_bitset< _WordT, _Alloc > & | reset () |
dynamic_bitset< _WordT, _Alloc > & | reset (size_type __pos) |
void | resize (size_type __nbits, bool __value=false) |
dynamic_bitset< _WordT, _Alloc > & | set () |
dynamic_bitset< _WordT, _Alloc > & | set (size_type __pos, bool __val=true) |
size_type | size () const |
void | swap (dynamic_bitset &__b) |
bool | test (size_type __pos) const |
template<typename _CharT = char, typename _Traits = std::char_traits<_CharT>, typename _Alloc1 = std::allocator<_CharT>> | |
std::basic_string< _CharT, _Traits, _Alloc1 > | to_string (_CharT __zero=_CharT('0'), _CharT __one=_CharT('1')) const |
unsigned long long | to_ullong () const |
unsigned long | to_ulong () const |
dynamic_bitset< _WordT, _Alloc > & | operator&= (const dynamic_bitset< _WordT, _Alloc > &__rhs) |
dynamic_bitset< _WordT, _Alloc > & | operator&= (dynamic_bitset< _WordT, _Alloc > &&__rhs) |
dynamic_bitset< _WordT, _Alloc > & | operator|= (const dynamic_bitset< _WordT, _Alloc > &__rhs) |
dynamic_bitset< _WordT, _Alloc > & | operator^= (const dynamic_bitset< _WordT, _Alloc > &__rhs) |
dynamic_bitset< _WordT, _Alloc > & | operator-= (const dynamic_bitset< _WordT, _Alloc > &__rhs) |
dynamic_bitset< _WordT, _Alloc > & | operator<<= (size_type __pos) |
dynamic_bitset< _WordT, _Alloc > & | operator>>= (size_type __pos) |
reference | operator[] (size_type __pos) |
const_reference | operator[] (size_type __pos) const |
dynamic_bitset< _WordT, _Alloc > | operator<< (size_type __pos) const |
dynamic_bitset< _WordT, _Alloc > | operator>> (size_type __pos) const |
Static Public Attributes | |
static const size_type | bits_per_block |
static const size_type | npos |
Private Member Functions | |
size_t | _M_are_all_aux () const |
void | _M_assign (const __dynamic_bitset_base &__b) |
void | _M_clear () |
void | _M_do_and (const __dynamic_bitset_base &__x) |
void | _M_do_append_block (block_type __block, size_type __pos) |
size_t | _M_do_count () const |
void | _M_do_dif (const __dynamic_bitset_base &__x) |
size_type | _M_do_find_first (size_t __not_found) const |
size_type | _M_do_find_next (size_t __prev, size_t __not_found) const |
void | _M_do_flip () |
void | _M_do_left_shift (size_t __shift) |
void | _M_do_or (const __dynamic_bitset_base &__x) |
void | _M_do_reset () |
void | _M_do_right_shift (size_t __shift) |
void | _M_do_set () |
unsigned long long | _M_do_to_ullong () const |
unsigned long | _M_do_to_ulong () const |
void | _M_do_xor (const __dynamic_bitset_base &__x) |
allocator_type | _M_get_allocator () const |
block_type & | _M_getword (size_type __pos) |
block_type | _M_getword (size_type __pos) const |
block_type & | _M_hiword () |
block_type | _M_hiword () const |
bool | _M_is_any () const |
bool | _M_is_equal (const __dynamic_bitset_base &__x) const |
bool | _M_is_less (const __dynamic_bitset_base &__x) const |
bool | _M_is_proper_subset_of (const __dynamic_bitset_base &__b) const |
bool | _M_is_subset_of (const __dynamic_bitset_base &__b) |
void | _M_resize (size_t __nbits, bool __value) |
size_type | _M_size () const |
void | _M_swap (__dynamic_bitset_base &__b) |
Private Attributes | |
std::vector< block_type, allocator_type > | _M_w |
Static Private Attributes | |
static const size_type | _S_bits_per_block |
Friends | |
class | reference |
The dynamic_bitset class represents a sequence of bits.
(Note that dynamic_bitset does not meet the formal requirements of a container. Mainly, it lacks iterators.)
The template argument, Nb, may be any non-negative number, specifying the number of bits (e.g., "0", "12", "1024*1024").
In the general unoptimized case, storage is allocated in word-sized blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B words will be used for storage. B - NbB bits are unused. (They are the high-order bits in the highest word.) It is a class invariant that those unused bits are always zero.
If you think of dynamic_bitset as "a simple array of bits," be aware that your mental picture is reversed: a dynamic_bitset behaves the same way as bits in integers do, with the bit at index 0 in the "least significant / right-hand" position, and the bit at index Nb-1 in the "most significant / left-hand" position. Thus, unlike other containers, a dynamic_bitset's index "counts from right to left," to put it very loosely.
This behavior is preserved when translating to and from strings. For example, the first line of the following program probably prints "b('a') is 0001100001" on a modern ASCII system.
Also see: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch33s02.html for a description of extensions.
Most of the actual code isn't contained in dynamic_bitset<> itself, but in the base class __dynamic_bitset_base. The base class works with whole words, not with individual bits. This allows us to specialize __dynamic_bitset_base for the important special case where the dynamic_bitset is only a single word.
Extra confusion can result due to the fact that the storage for __dynamic_bitset_base is a vector, and is indexed as such. This is carefully encapsulated.
Definition at line 570 of file dynamic_bitset.
|
inlineexplicit |
All bits set to zero.
Definition at line 722 of file dynamic_bitset.
|
inlineexplicit |
Initial bits bitwise-copied from a single word (others set to zero).
Definition at line 728 of file dynamic_bitset.
|
inlineexplicit |
Use a subset of a string.
__str | A string of '0' and '1' characters. |
__pos | Index of the first character in __str to use. |
__n | The number of characters to copy. |
std::out_of_range | If __pos is bigger the size of __str . |
std::invalid_argument | If a character appears in the string which is neither '0' nor '1'. |
Definition at line 750 of file dynamic_bitset.
References std::tr2::dynamic_bitset< _WordT, _Alloc >::resize(), and std::basic_string< _CharT, _Traits, _Alloc >::size().
|
inlineexplicit |
Construct from a string.
__str | A string of '0' and '1' characters. |
std::invalid_argument | If a character appears in the string which is neither '0' nor '1'. |
Definition at line 778 of file dynamic_bitset.
References std::tr2::dynamic_bitset< _WordT, _Alloc >::resize().
|
inline |
Copy constructor.
Definition at line 794 of file dynamic_bitset.
|
inline |
Move constructor.
Definition at line 801 of file dynamic_bitset.
|
inline |
Tests whether all the bits are on.
Definition at line 1187 of file dynamic_bitset.
|
inline |
Tests whether any of the bits are on.
Definition at line 1195 of file dynamic_bitset.
|
inline |
Append a block.
Definition at line 882 of file dynamic_bitset.
Referenced by std::tr2::dynamic_bitset< _WordT, _Alloc >::append().
|
inline |
Append an iterator range of blocks.
Definition at line 900 of file dynamic_bitset.
References std::tr2::dynamic_bitset< _WordT, _Alloc >::append().
|
inline |
Clear the bitset.
Definition at line 860 of file dynamic_bitset.
|
inline |
Returns the number of bits which are set.
Definition at line 1144 of file dynamic_bitset.
|
inline |
Returns true if the dynamic_bitset is empty.
Definition at line 1158 of file dynamic_bitset.
|
inline |
Finds the index of the first "on" bit.
Definition at line 1223 of file dynamic_bitset.
|
inline |
Finds the index of the next "on" bit after prev.
__prev | Where to start searching. |
Definition at line 1233 of file dynamic_bitset.
|
inline |
Toggles every bit to its opposite value.
Definition at line 1039 of file dynamic_bitset.
Referenced by std::tr2::dynamic_bitset< _WordT, _Alloc >::operator~().
|
inline |
Toggles a given bit to its opposite value.
__pos | The index of the bit. |
std::out_of_range | If __pos is bigger the size of the set. |
Definition at line 1052 of file dynamic_bitset.
|
inline |
Return the allocator for the bitset.
Definition at line 842 of file dynamic_bitset.
|
inline |
Returns the maximum size of a dynamic_bitset object having the same type as *this. The real answer is max() * bits_per_block but is likely to overflow.
Definition at line 1165 of file dynamic_bitset.
References std::numeric_limits< _Tp >::max().
|
inline |
Tests whether any of the bits are on.
Definition at line 1203 of file dynamic_bitset.
|
inline |
Returns the total number of blocks.
Definition at line 1153 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__rhs | A same-sized dynamic_bitset. |
These should be self-explanatory.
Definition at line 915 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__rhs | A same-sized dynamic_bitset. |
These should be self-explanatory.
Definition at line 922 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__rhs | A same-sized dynamic_bitset. |
These should be self-explanatory.
Definition at line 943 of file dynamic_bitset.
|
inline |
Self-explanatory.
Definition at line 1209 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__pos | The number of places to shift. |
These should be self-explanatory.
Definition at line 958 of file dynamic_bitset.
|
inline |
Assignment.
Definition at line 819 of file dynamic_bitset.
|
inline |
Move assignment.
Definition at line 832 of file dynamic_bitset.
References std::tr2::dynamic_bitset< _WordT, _Alloc >::swap().
|
inline |
Self-explanatory.
Definition at line 1213 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__pos | The number of places to shift. |
These should be self-explanatory.
Definition at line 971 of file dynamic_bitset.
|
inline |
Array-indexing support.
__pos | Index into the dynamic_bitset. |
Definition at line 1074 of file dynamic_bitset.
|
inline |
Array-indexing support.
__pos | Index into the dynamic_bitset. |
Definition at line 1078 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__rhs | A same-sized dynamic_bitset. |
These should be self-explanatory.
Definition at line 936 of file dynamic_bitset.
|
inline |
Operations on dynamic_bitsets.
__rhs | A same-sized dynamic_bitset. |
These should be self-explanatory.
Definition at line 929 of file dynamic_bitset.
|
inline |
See the no-argument flip().
Definition at line 1061 of file dynamic_bitset.
References std::tr2::dynamic_bitset< _WordT, _Alloc >::flip().
|
inline |
Push a bit onto the high end of the bitset.
Definition at line 870 of file dynamic_bitset.
References std::tr2::dynamic_bitset< _WordT, _Alloc >::size().
|
inline |
Sets every bit to false.
Definition at line 1014 of file dynamic_bitset.
|
inline |
Sets a given bit to false.
__pos | The index of the bit. |
std::out_of_range | If __pos is bigger the size of the set. |
Same as writing set(__pos, false)
.
Definition at line 1028 of file dynamic_bitset.
|
inline |
Resize the bitset.
Definition at line 849 of file dynamic_bitset.
Referenced by std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset(), and std::tr2::operator>>().
|
inline |
Sets every bit to true.
Definition at line 989 of file dynamic_bitset.
|
inline |
Sets a given bit to a particular value.
__pos | The index of the bit. |
__val | Either true or false, defaults to true. |
std::out_of_range | If __pos is bigger the size of the set. |
Definition at line 1003 of file dynamic_bitset.
|
inline |
Returns the total number of bits.
Definition at line 1149 of file dynamic_bitset.
Referenced by std::tr2::operator>>(), and std::tr2::dynamic_bitset< _WordT, _Alloc >::push_back().
|
inline |
Swap with another bitset.
Definition at line 809 of file dynamic_bitset.
Referenced by std::tr2::dynamic_bitset< _WordT, _Alloc >::operator=().
|
inline |
Tests the value of a bit.
__pos | The index of a bit. |
std::out_of_range | If __pos is bigger the size of the set. |
Definition at line 1175 of file dynamic_bitset.
|
inline |
Returns a character interpretation of the dynamic_bitset.
Note the ordering of the bits: decreasing character positions correspond to increasing bit positions (see the main class notes for an example).
Definition at line 1114 of file dynamic_bitset.
|
inline |
Returns a numerical interpretation of the dynamic_bitset.
std::overflow_error | If there are too many bits to be represented in an unsigned long . |
Definition at line 1099 of file dynamic_bitset.
|
inline |
Returns a numerical interpretation of the dynamic_bitset.
std::overflow_error | If there are too many bits to be represented in an unsigned long . |
Definition at line 1089 of file dynamic_bitset.