Template class to hold a range of items using a custom bitmap.
More...
#include <fixed_size_bitmap.hpp>
|
| BitmapRange () noexcept |
| Default constructor.
|
|
| BitmapRange (T base) noexcept |
| Base-specific constructor.
|
|
| BitmapRange (T base, uint32_t max_bits) noexcept |
| Range specific constructor.
|
|
T | base () const noexcept |
| Get base of the range.
|
|
void | base (T base) noexcept |
| Set a new base for the range.
|
|
void | base (T base, uint32_t max_bits) noexcept |
| Set a new base and maximum bits for the range.
|
|
void | base_update (T base) noexcept |
| Set a new base for the range, keeping old values where possible.
|
|
bool | empty () const noexcept |
| Returns whether the range is empty (i.e.
|
|
T | max () const noexcept |
| Returns the highest value set in the range.
|
|
T | min () const noexcept |
| Returns the lowest value set in the range.
|
|
bool | is_set (const T &item) const noexcept |
| Checks if an element is present in the bitmap.
|
|
bool | add (const T &item) noexcept |
| Adds an element to the range.
|
|
void | add_range (const T &from, const T &to) |
| Adds a range of elements to the range.
|
|
void | remove (const T &item) noexcept |
| Removes an element from the range.
|
|
void | bitmap_get (uint32_t &num_bits, bitmap_type &bitmap, uint32_t &num_longs_used) const noexcept |
| Gets the current value of the bitmap.
|
|
void | bitmap_set (uint32_t num_bits, const uint32_t *bitmap) noexcept |
| Sets the current value of the bitmap.
|
|
template<class UnaryFunc > |
void | for_each (UnaryFunc f) const |
| Apply a function on every item on the range.
|
|
template<class T, class Diff = DiffFunction<T>, uint32_t NBITS = 256>
class eprosima::fastrtps::BitmapRange< T, Diff, NBITS >
Template class to hold a range of items using a custom bitmap.
- Template Parameters
-
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]. |
◆ bitmap_type
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
◆ BitmapRange() [1/3]
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Default constructor.
Constructs an empty range with default base.
◆ BitmapRange() [2/3]
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Base-specific constructor.
Constructs an empty range with specified base.
- Parameters
-
base | Specific base value for the created range. |
◆ BitmapRange() [3/3]
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Range specific constructor.
Constructs an empty range with specified base and maximum bits.
- Parameters
-
base | Specific base value for the created range. |
max_bits | Specific maximum number of bits. |
◆ add()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
bool add |
( |
const T & |
item | ) |
|
|
inlinenoexcept |
Adds an element to the range.
Adds an element to the bitmap if it is in the allowed range.
- Parameters
-
- Returns
- true if the item has been added (i.e. is in the allowed range), false otherwise.
◆ add_range()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void add_range |
( |
const T & |
from, |
|
|
const T & |
to |
|
) |
| |
|
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);
- Parameters
-
from | Starting value of the range to add. |
to | Ending value of the range to add. |
◆ base() [1/3]
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Get base of the range.
- Returns
- a copy of the range base.
◆ base() [2/3]
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Set a new base for the range.
This method resets the range and sets a new value for its base.
- Parameters
-
base | New base value to set. |
◆ base() [3/3]
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void base |
( |
T |
base, |
|
|
uint32_t |
max_bits |
|
) |
| |
|
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.
- Parameters
-
base | New base value to set. |
max_bits | New maximum number of bits. |
◆ base_update()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void base_update |
( |
T |
base | ) |
|
|
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.
- Parameters
-
base | New base value to set. |
◆ bitmap_get()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void bitmap_get |
( |
uint32_t & |
num_bits, |
|
|
bitmap_type & |
bitmap, |
|
|
uint32_t & |
num_longs_used |
|
) |
| const |
|
inlinenoexcept |
Gets the current value of the bitmap.
This method is designed to be used when performing serialization of a bitmap range.
- Parameters
-
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. |
◆ bitmap_set()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void bitmap_set |
( |
uint32_t |
num_bits, |
|
|
const uint32_t * |
bitmap |
|
) |
| |
|
inlinenoexcept |
Sets the current value of the bitmap.
This method is designed to be used when performing deserialization of a bitmap range.
- Parameters
-
num_bits | Number of significant bits in the input bitmap. |
bitmap | Points to the beginning of a uint32_t array holding the input bitmap. |
◆ empty()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Returns whether the range is empty (i.e.
has all bits unset).
- Returns
- true if the range is empty, false otherwise.
◆ for_each()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
template<class UnaryFunc >
void for_each |
( |
UnaryFunc |
f | ) |
const |
|
inline |
Apply a function on every item on the range.
- Parameters
-
f | Function to apply on each item. |
◆ is_set()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
bool is_set |
( |
const T & |
item | ) |
const |
|
inlinenoexcept |
Checks if an element is present in the bitmap.
- Parameters
-
- Returns
- true if the item is present in the bitmap, false otherwise.
◆ max()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Returns the highest value set in the range.
- Returns
- the highest value set in the range. If the range is empty, the result is undetermined.
◆ min()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Returns the lowest value set in the range.
- Returns
- the lowest value set in the range. If the range is empty, the result is undetermined.
◆ remove()
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void remove |
( |
const T & |
item | ) |
|
|
inlinenoexcept |
Removes an element from the range.
Removes an element from the bitmap.
- Parameters
-
◆ base_
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Holds base value of the range.
◆ bitmap_
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
◆ num_bits_
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Holds the highest bit set in the bitmap.
◆ range_max_
template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
Holds maximum allowed value of the range.
The documentation for this class was generated from the following file: