other versions
- wheezy 4.7.2-5
std::tr2::dynamic_bitset< _WordT, _Alloc >(3cxx) | std::tr2::dynamic_bitset< _WordT, _Alloc >(3cxx) |
NAME¶
std::tr2::dynamic_bitset< _WordT, _Alloc > -SYNOPSIS¶
Inherits std::tr2::__dynamic_bitset_base< _WordT, _Alloc >.Classes¶
class reference
Public Types¶
typedef __dynamic_bitset_base
Public Member Functions¶
dynamic_bitset (const allocator_type &__alloc=allocator_type())
dynamic_bitset< _WordT, _Alloc > & operator&= (const dynamic_bitset< _WordT, _Alloc > &__rhs)
dynamic_bitset< _WordT, _Alloc > & operator<<= (size_type __pos)
reference operator[] (size_type __pos)
dynamic_bitset< _WordT, _Alloc > operator<< (size_type __pos) const
Static Public Attributes¶
static const size_type bits_per_block
Private Member Functions¶
size_t _M_are_all_aux () const
Static Private Member Functions¶
static block_type _S_maskbit (size_type __pos)
Private Attributes¶
std::vector< block_type,
Static Private Attributes¶
static const size_type _S_bits_per_block
Friends¶
class reference
Detailed Description¶
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>class std::tr2::dynamic_bitset< _WordT, _Alloc >¶
The dynamic_bitset class represents a sequence of bits.#include <dynamic_bitset> #include <iostream> #include <sstream> using namespace std; int main() { long a = 'a'; dynamic_bitset b(a); cout << 'b('a') is ' << b << endl; ostringstream s; s << b; string str = s.str(); cout << 'index 3 in the string is ' << str[3] << ' but0 << 'index 3 in the bitset is ' << b[3] << endl; }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.
Constructor & Destructor Documentation¶
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> std::tr2::dynamic_bitset< _WordT, _Alloc >:: dynamic_bitset (const allocator_type &__alloc = allocator_type()) [inline], [explicit]¶
All bits set to zero. Definition at line 722 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> std::tr2::dynamic_bitset< _WordT, _Alloc >:: dynamic_bitset (size_type__nbits, unsigned long long__val = 0ULL, const allocator_type &__alloc = allocator_type()) [inline], [explicit]¶
Initial bits bitwise-copied from a single word (others set to zero). Definition at line 728 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> template<typename _CharT , typename _Traits , typename _Alloc1 > std::tr2::dynamic_bitset< _WordT, _Alloc >:: 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() ) [inline], [explicit] ¶
Use a subset of a string. Parameters:__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.
Exceptions:
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'.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> std::tr2::dynamic_bitset< _WordT, _Alloc >:: dynamic_bitset (const char *__str, const allocator_type &__alloc = allocator_type()) [inline], [explicit]¶
Construct from a string. Parameters:__str A string of '0' and '1'
characters.
Exceptions:
std::invalid_argument
If a character appears in the string which is neither '0' nor '1'.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> std::tr2::dynamic_bitset< _WordT, _Alloc >:: dynamic_bitset (const dynamic_bitset< _WordT, _Alloc > &__b) [inline]¶
Copy constructor. Definition at line 794 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> std::tr2::dynamic_bitset< _WordT, _Alloc >:: dynamic_bitset (dynamic_bitset< _WordT, _Alloc > &&__b) [inline]¶
Move constructor. Definition at line 801 of file dynamic_bitset.Member Function Documentation¶
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> bool std::tr2::dynamic_bitset< _WordT, _Alloc >::all () const [inline]¶
Tests whether all the bits are on. Returns:True if all the bits are set.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> bool std::tr2::dynamic_bitset< _WordT, _Alloc >::any () const [inline]¶
Tests whether any of the bits are on. Returns:True if at least one bit is set.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> void std::tr2::dynamic_bitset< _WordT, _Alloc >::append (block_type__block) [inline]¶
Append a block. Definition at line 882 of file dynamic_bitset. Referenced by std::tr2::dynamic_bitset< _WordT, _Alloc >::append().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> template<typename _BlockInputIterator > void std::tr2::dynamic_bitset< _WordT, _Alloc >::append (_BlockInputIterator__first, _BlockInputIterator__last) [inline]¶
Append an iterator range of blocks. Definition at line 900 of file dynamic_bitset. References std::tr2::dynamic_bitset< _WordT, _Alloc >::append().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> void std::tr2::dynamic_bitset< _WordT, _Alloc >::clear () [inline]¶
Clear the bitset. Definition at line 860 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::count () const [inline]¶
Returns the number of bits which are set. Definition at line 1144 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> bool std::tr2::dynamic_bitset< _WordT, _Alloc >::empty () const [inline]¶
Returns true if the dynamic_bitset is empty. Definition at line 1158 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::find_first () const [inline]¶
Finds the index of the first 'on' bit. Returns:The index of the first bit set, or
size() if not found.
See Also:
find_next
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::find_next (size_t__prev) const [inline]¶
Finds the index of the next 'on' bit after prev. Returns:The index of the next bit set, or
size() if not found.
Parameters:
__prev Where to start searching.
See Also:
find_first
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::flip () [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~().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::flip (size_type__pos) [inline]¶
Toggles a given bit to its opposite value. Parameters:__pos The index of the bit.
Exceptions:
std::out_of_range If
__pos is bigger the size of the set.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> allocator_type std::tr2::dynamic_bitset< _WordT, _Alloc >::get_allocator () const [inline]¶
Return the allocator for the bitset. Definition at line 842 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::max_size () const [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().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> bool std::tr2::dynamic_bitset< _WordT, _Alloc >::none () const [inline]¶
Tests whether any of the bits are on. Returns:True if none of the bits are set.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::num_blocks () const [inline]¶
Returns the total number of blocks. Definition at line 1153 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator&= (const dynamic_bitset< _WordT, _Alloc > &__rhs) [inline]¶
Operations on dynamic_bitsets. Parameters:__rhs A same-sized
dynamic_bitset.
These should be self-explanatory.
Definition at line 915 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator&= ( dynamic_bitset< _WordT, _Alloc > &&__rhs) [inline]¶
Operations on dynamic_bitsets. Parameters:__rhs A same-sized
dynamic_bitset.
These should be self-explanatory.
Definition at line 922 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator-= (const dynamic_bitset< _WordT, _Alloc > &__rhs) [inline]¶
Operations on dynamic_bitsets. Parameters:__rhs A same-sized
dynamic_bitset.
These should be self-explanatory.
Definition at line 943 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc> std::tr2::dynamic_bitset< _WordT, _Alloc >::operator<< (size_type__pos) const [inline]¶
Self-explanatory. Definition at line 1209 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator<<= (size_type__pos) [inline]¶
Operations on dynamic_bitsets. Parameters:__pos The number of places to
shift.
These should be self-explanatory.
Definition at line 958 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator= (const dynamic_bitset< _WordT, _Alloc > &__b) [inline]¶
Assignment. Definition at line 819 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator= ( dynamic_bitset< _WordT, _Alloc > &&__b) [inline]¶
Move assignment. Definition at line 832 of file dynamic_bitset. References std::tr2::dynamic_bitset< _WordT, _Alloc >::swap().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc> std::tr2::dynamic_bitset< _WordT, _Alloc >::operator>> (size_type__pos) const [inline]¶
Self-explanatory. Definition at line 1213 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator>>= (size_type__pos) [inline]¶
Operations on dynamic_bitsets. Parameters:__pos The number of places to
shift.
These should be self-explanatory.
Definition at line 971 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> reference std::tr2::dynamic_bitset< _WordT, _Alloc >::operator[] (size_type__pos) [inline]¶
Array-indexing support. Parameters:__pos Index into the
dynamic_bitset.
Returns:
A bool for a 'const dynamic_bitset'. For
non-const bitsets, an instance of the reference proxy class.
Note:
These operators do no range checking and throw
no exceptions, as required by DR 11 to the standard.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> const_reference std::tr2::dynamic_bitset< _WordT, _Alloc >::operator[] (size_type__pos) const [inline]¶
Array-indexing support. Parameters:__pos Index into the
dynamic_bitset.
Returns:
A bool for a 'const dynamic_bitset'. For
non-const bitsets, an instance of the reference proxy class.
Note:
These operators do no range checking and throw
no exceptions, as required by DR 11 to the standard.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator^= (const dynamic_bitset< _WordT, _Alloc > &__rhs) [inline]¶
Operations on dynamic_bitsets. Parameters:__rhs A same-sized
dynamic_bitset.
These should be self-explanatory.
Definition at line 936 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::operator|= (const dynamic_bitset< _WordT, _Alloc > &__rhs) [inline]¶
Operations on dynamic_bitsets. Parameters:__rhs A same-sized
dynamic_bitset.
These should be self-explanatory.
Definition at line 929 of file dynamic_bitset.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc> std::tr2::dynamic_bitset< _WordT, _Alloc >::operator~ () const [inline]¶
See the no-argument flip(). Definition at line 1061 of file dynamic_bitset. References std::tr2::dynamic_bitset< _WordT, _Alloc >::flip().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> void std::tr2::dynamic_bitset< _WordT, _Alloc >::push_back (bool__bit) [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().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::reset () [inline]¶
Sets every bit to false. Definition at line 1014 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::reset (size_type__pos) [inline]¶
Sets a given bit to false. Parameters:__pos The index of the bit.
Exceptions:
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.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> void std::tr2::dynamic_bitset< _WordT, _Alloc >::resize (size_type__nbits, bool__value = false) [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>>().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::set () [inline]¶
Sets every bit to true. Definition at line 989 of file dynamic_bitset.template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> dynamic_bitset<_WordT, _Alloc>& std::tr2::dynamic_bitset< _WordT, _Alloc >::set (size_type__pos, bool__val = true) [inline]¶
Sets a given bit to a particular value. Parameters:__pos The index of the bit.
__val Either true or false, defaults to true.
Exceptions:
std::out_of_range If
__pos is bigger the size of the set.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::size () const [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().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> void std::tr2::dynamic_bitset< _WordT, _Alloc >::swap ( dynamic_bitset< _WordT, _Alloc > &__b) [inline]¶
Swap with another bitset. Definition at line 809 of file dynamic_bitset. Referenced by std::tr2::dynamic_bitset< _WordT, _Alloc >::operator=().template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> bool std::tr2::dynamic_bitset< _WordT, _Alloc >::test (size_type__pos) const [inline]¶
Tests the value of a bit. Parameters:__pos The index of a bit.
Returns:
The value at __pos.
Exceptions:
std::out_of_range If
__pos is bigger the size of the set.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> template<typename _CharT = char, typename _Traits = std::char_traits<_CharT>, typename _Alloc1 = std::allocator<_CharT>> std::basic_string<_CharT, _Traits, _Alloc1> std::tr2::dynamic_bitset< _WordT, _Alloc >::to_string (_CharT__zero = _CharT('0'), _CharT__one = _CharT('1')) const [inline]¶
Returns a character interpretation of the dynamic_bitset. Returns:The string equivalent of the bits.
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.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> unsigned long long std::tr2::dynamic_bitset< _WordT, _Alloc >::to_ullong () const [inline]¶
Returns a numerical interpretation of the dynamic_bitset. Returns:The integral equivalent of the bits.
Exceptions:
std::overflow_error If
there are too many bits to be represented in an unsigned
long.
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>> unsigned long std::tr2::dynamic_bitset< _WordT, _Alloc >::to_ulong () const [inline]¶
Returns a numerical interpretation of the dynamic_bitset. Returns:The integral equivalent of the bits.
Exceptions:
std::overflow_error If
there are too many bits to be represented in an unsigned
long.
Author¶
Generated automatically by Doxygen for libstdc++ from the source code.Sun Jan 6 2013 | libstdc++ |