Bitcoin Core 28.99.0
P2P Digital Currency
|
Class that mimics std::deque<bool>, but with std::vector<bool>'s bit packing. More...
#include <bitdeque.h>
Classes | |
class | Iterator |
Iterator to a bitdeque element, const or not. More... | |
Public Types | |
using | value_type = bool |
using | size_type = std::size_t |
using | difference_type = typename deque_type::difference_type |
using | reference = typename word_type::reference |
using | const_reference = bool |
using | iterator = Iterator< false > |
using | const_iterator = Iterator< true > |
using | pointer = void |
using | const_pointer = void |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Public Member Functions | |
bitdeque () | |
Construct an empty container. More... | |
void | assign (size_type count, bool val) |
Set the container equal to count times the value of val. More... | |
bitdeque (size_type count, bool val) | |
Construct a container containing count times the value of val. More... | |
bitdeque (size_t count) | |
Construct a container containing count false values. More... | |
bitdeque (const bitdeque &)=default | |
Copy constructor. More... | |
bitdeque (bitdeque &&) noexcept=default | |
Move constructor. More... | |
bitdeque & | operator= (const bitdeque &other)=default |
Copy assignment operator. More... | |
bitdeque & | operator= (bitdeque &&other) noexcept=default |
Move assignment operator. More... | |
iterator | begin () noexcept |
iterator | end () noexcept |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
reverse_iterator | rbegin () noexcept |
reverse_iterator | rend () noexcept |
const_reverse_iterator | rbegin () const noexcept |
const_reverse_iterator | crbegin () const noexcept |
const_reverse_iterator | rend () const noexcept |
const_reverse_iterator | crend () const noexcept |
size_type | size () const noexcept |
Count the number of bits in the container. More... | |
bool | empty () const noexcept |
Determine whether the container is empty. More... | |
size_type | max_size () const noexcept |
Return the maximum size of the container. More... | |
template<typename It > | |
void | assign (It first, It last) |
Set the container equal to the bits in [first,last). More... | |
void | assign (std::initializer_list< bool > ilist) |
Set the container equal to the bits in ilist. More... | |
bitdeque & | operator= (std::initializer_list< bool > ilist) |
Set the container equal to the bits in ilist. More... | |
template<typename It > | |
bitdeque (It first, It last) | |
Construct a container containing the bits in [first,last). More... | |
bitdeque (std::initializer_list< bool > ilist) | |
Construct a container containing the bits in ilist. More... | |
reference | at (size_type position) |
const_reference | at (size_type position) const |
reference | operator[] (size_type position) |
const_reference | operator[] (size_type position) const |
reference | front () |
const_reference | front () const |
reference | back () |
const_reference | back () const |
void | shrink_to_fit () |
Release unused memory. More... | |
void | clear () noexcept |
Empty the container. More... | |
void | push_back (bool val) |
reference | emplace_back (bool val) |
void | push_front (bool val) |
reference | emplace_front (bool val) |
void | pop_back () |
void | pop_front () |
void | resize (size_type n) |
Resize the container. More... | |
void | swap (bitdeque &other) noexcept |
iterator | erase (const_iterator first, const_iterator last) |
iterator | erase (iterator first, iterator last) |
iterator | erase (const_iterator pos) |
iterator | erase (iterator pos) |
iterator | insert (const_iterator pos, bool val) |
iterator | emplace (const_iterator pos, bool val) |
iterator | insert (const_iterator pos, size_type count, bool val) |
template<typename It > | |
iterator | insert (const_iterator pos, It first, It last) |
Private Types | |
using | word_type = std::bitset< BITS_PER_WORD > |
using | deque_type = std::deque< word_type > |
Private Member Functions | |
void | erase_back (size_type n) |
Shrink the container by n bits, removing from the end. More... | |
void | extend_back (size_type n) |
Extend the container by n bits, adding at the end. More... | |
void | erase_front (size_type n) |
Shrink the container by n bits, removing from the beginning. More... | |
void | extend_front (size_type n) |
Extend the container by n bits, adding at the beginning. More... | |
void | insert_zeroes (size_type before, size_type count) |
Insert a sequence of falses anywhere in the container. More... | |
Private Attributes | |
deque_type | m_deque |
Deque of bitsets storing the actual bit data. More... | |
int | m_pad_begin |
Number of unused bits at the front of m_deque.front(). More... | |
int | m_pad_end |
Number of unused bits at the back of m_deque.back(). More... | |
Friends | |
template<bool Const> | |
class | Iterator |
void | swap (bitdeque &b1, bitdeque &b2) noexcept |
Class that mimics std::deque<bool>, but with std::vector<bool>'s bit packing.
BITS_PER_WORD selects the (minimum) number of bits that are allocated at once. Larger values reduce the asymptotic memory usage overhead, at the cost of needing larger up-front allocations. The default is 4096 bytes.
Definition at line 22 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::const_iterator = Iterator<true> |
Definition at line 119 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::const_pointer = void |
Definition at line 121 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::const_reference = bool |
Definition at line 117 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 123 of file bitdeque.h.
|
private |
Definition at line 26 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::difference_type = typename deque_type::difference_type |
Definition at line 115 of file bitdeque.h.
Definition at line 118 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::pointer = void |
Definition at line 120 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::reference = typename word_type::reference |
Definition at line 116 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::reverse_iterator = std::reverse_iterator<iterator> |
Definition at line 122 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::size_type = std::size_t |
Definition at line 114 of file bitdeque.h.
using bitdeque< BITS_PER_WORD >::value_type = bool |
Definition at line 113 of file bitdeque.h.
|
private |
Definition at line 25 of file bitdeque.h.
|
inlineexplicit |
Construct an empty container.
Definition at line 212 of file bitdeque.h.
|
inline |
Construct a container containing count times the value of val.
Definition at line 230 of file bitdeque.h.
|
inlineexplicit |
Construct a container containing count false values.
Definition at line 233 of file bitdeque.h.
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
inline |
Construct a container containing the bits in [first,last).
Definition at line 312 of file bitdeque.h.
|
inline |
Construct a container containing the bits in ilist.
Definition at line 315 of file bitdeque.h.
|
inline |
Set the container equal to the bits in [first,last).
Definition at line 282 of file bitdeque.h.
|
inline |
Set the container equal to count times the value of val.
Definition at line 215 of file bitdeque.h.
|
inline |
Set the container equal to the bits in ilist.
Definition at line 293 of file bitdeque.h.
|
inline |
Definition at line 334 of file bitdeque.h.
|
inline |
|
inlinenoexcept |
Definition at line 250 of file bitdeque.h.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Empty the container.
Definition at line 344 of file bitdeque.h.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
Determine whether the container is empty.
Definition at line 265 of file bitdeque.h.
|
inlinenoexcept |
Definition at line 252 of file bitdeque.h.
|
inline |
|
inline |
Definition at line 427 of file bitdeque.h.
|
inline |
Definition at line 426 of file bitdeque.h.
|
inline |
Definition at line 428 of file bitdeque.h.
|
inlineprivate |
Shrink the container by n bits, removing from the end.
Definition at line 136 of file bitdeque.h.
|
inlineprivate |
Shrink the container by n bits, removing from the beginning.
Definition at line 167 of file bitdeque.h.
|
inlineprivate |
Extend the container by n bits, adding at the end.
Definition at line 155 of file bitdeque.h.
|
inlineprivate |
Extend the container by n bits, adding at the beginning.
Definition at line 186 of file bitdeque.h.
Definition at line 332 of file bitdeque.h.
|
inline |
|
inline |
Definition at line 431 of file bitdeque.h.
|
inline |
|
inline |
|
inlineprivate |
Insert a sequence of falses anywhere in the container.
Definition at line 198 of file bitdeque.h.
|
inlinenoexcept |
Return the maximum size of the container.
Definition at line 271 of file bitdeque.h.
|
defaultnoexcept |
Move assignment operator.
|
default |
Copy assignment operator.
|
inline |
Set the container equal to the bits in ilist.
Definition at line 304 of file bitdeque.h.
|
inline |
|
inline |
|
inline |
Definition at line 385 of file bitdeque.h.
|
inline |
Definition at line 351 of file bitdeque.h.
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Resize the container.
Definition at line 391 of file bitdeque.h.
|
inline |
Release unused memory.
Definition at line 338 of file bitdeque.h.
|
inlinenoexcept |
Count the number of bits in the container.
Definition at line 262 of file bitdeque.h.
|
inlinenoexcept |
Definition at line 401 of file bitdeque.h.
Definition at line 31 of file bitdeque.h.
|
friend |
Definition at line 407 of file bitdeque.h.
|
private |
Deque of bitsets storing the actual bit data.
Definition at line 127 of file bitdeque.h.
|
private |
Number of unused bits at the front of m_deque.front().
Definition at line 130 of file bitdeque.h.
|
private |
Number of unused bits at the back of m_deque.back().
Definition at line 133 of file bitdeque.h.