Template class to hold a range of items using a custom bitmap. More...
#include <fixed_size_bitmap.hpp>
Public Types | |
| using | bitmap_type = std::array< uint32_t, NITEMS > |
Public Member Functions | |
| BitmapRange () noexcept | |
| Default constructor. More... | |
| BitmapRange (T base) noexcept | |
| Base-specific constructor. More... | |
| BitmapRange (T base, uint32_t max_bits) noexcept | |
| Range specific constructor. More... | |
| T | base () const noexcept |
| Get base of the range. More... | |
| void | base (T base) noexcept |
| Set a new base for the range. More... | |
| void | base (T base, uint32_t max_bits) noexcept |
| Set a new base and maximum bits for the range. More... | |
| void | base_update (T base) noexcept |
| Set a new base for the range, keeping old values where possible. More... | |
| bool | empty () const noexcept |
| Returns whether the range is empty (i.e. More... | |
| T | max () const noexcept |
| Returns the highest value set in the range. More... | |
| T | min () const noexcept |
| Returns the lowest value set in the range. More... | |
| bool | is_set (const T &item) const noexcept |
| Checks if an element is present in the bitmap. More... | |
| bool | add (const T &item) noexcept |
| Adds an element to the range. More... | |
| void | add_range (const T &from, const T &to) |
| Adds a range of elements to the range. More... | |
| void | remove (const T &item) noexcept |
| Removes an element from the range. More... | |
| void | bitmap_get (uint32_t &num_bits, bitmap_type &bitmap, uint32_t &num_longs_used) const noexcept |
| Gets the current value of the bitmap. More... | |
| void | bitmap_set (uint32_t num_bits, const uint32_t *bitmap) noexcept |
| Sets the current value of the bitmap. More... | |
| template<class UnaryFunc > | |
| void | for_each (UnaryFunc f) const |
| Apply a function on every item on the range. More... | |
Protected Attributes | |
| T | base_ |
| Holds base value of the range. More... | |
| T | range_max_ |
| Holds maximum allowed value of the range. More... | |
| bitmap_type | bitmap_ |
| Holds the bitmap values. More... | |
| uint32_t | num_bits_ |
| Holds the highest bit set in the bitmap. More... | |
Template class to hold a range of items using a custom bitmap.
| T | Type of the elements in the range. Should have >= operator and T + uint32_t returning T. |
| Diff | Functor calculating the difference of two T. The result should be assignable to a uint32_t. |
| NBITS | Size in bits of the bitmap. Range of items will be [base, base + NBITS - 1]. |
| using bitmap_type = std::array<uint32_t, NITEMS> |
|
inlinenoexcept |
Default constructor.
Constructs an empty range with default base.
|
inlineexplicitnoexcept |
Base-specific constructor.
Constructs an empty range with specified base.
| base | Specific base value for the created range. |
|
inlinenoexcept |
Range specific constructor.
Constructs an empty range with specified base and maximum bits.
| base | Specific base value for the created range. |
| max_bits | Specific maximum number of bits. |
|
inlinenoexcept |
Adds an element to the range.
Adds an element to the bitmap if it is in the allowed range.
| item | Value to be added. |
|
inline |
Adds a range of elements to the range.
Add all elements in [from, to) to the range. Equivalent to for(T i = from; i < to; i++) add(i);
| from | Starting value of the range to add. |
| to | Ending value of the range to add. |
|
inlinenoexcept |
Get base of the range.
|
inlinenoexcept |
Set a new base for the range.
This method resets the range and sets a new value for its base.
| base | New base value to set. |
|
inlinenoexcept |
Set a new base and maximum bits for the range.
This method resets the range and sets a new value for its base, as long as a maximum number of bits.
| base | New base value to set. |
| max_bits | New maximum number of bits. |
|
inlinenoexcept |
Set a new base for the range, keeping old values where possible.
This method implements a sliding window mechanism for changing the base of the range.
| base | New base value to set. |
|
inlinenoexcept |
Gets the current value of the bitmap.
This method is designed to be used when performing serialization of a bitmap range.
| num_bits | Upon return, it will contain the number of significant bits in the bitmap. |
| bitmap | Upon return, it will contain the current value of the bitmap. |
| num_longs_used | Upon return, it will contain the number of valid elements on the returned bitmap. |
|
inlinenoexcept |
Sets the current value of the bitmap.
This method is designed to be used when performing deserialization of a bitmap range.
| num_bits | Number of significant bits in the input bitmap. |
| bitmap | Points to the beginning of a uint32_t array holding the input bitmap. |
|
inlinenoexcept |
Returns whether the range is empty (i.e.
has all bits unset).
|
inline |
Apply a function on every item on the range.
| f | Function to apply on each item. |
|
inlinenoexcept |
Checks if an element is present in the bitmap.
| item | Value to be checked. |
|
inlinenoexcept |
Returns the highest value set in the range.
|
inlinenoexcept |
Returns the lowest value set in the range.
|
inlinenoexcept |
Removes an element from the range.
Removes an element from the bitmap.
| item | Value to be removed. |
|
protected |
Holds base value of the range.
|
protected |
Holds the bitmap values.
|
protected |
Holds the highest bit set in the bitmap.
|
protected |
Holds maximum allowed value of the range.