Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
BitmapRange< T, Diff, NBITS > Class Template Reference

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.
 
 BitmapRange (T base) noexcept
 Base-specific constructor.
 
 BitmapRange (T base, uint32_t max_bits) noexcept
 Range specific constructor.
 
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.
 
max () const noexcept
 Returns the highest value set in the range.
 
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.
 

Protected Attributes

base_
 Holds base value of the range.
 
range_max_
 Holds maximum allowed value of the range.
 
bitmap_type bitmap_
 Holds the bitmap values.
 
uint32_t num_bits_
 Holds the highest bit set in the bitmap.
 

Detailed Description

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
TType of the elements in the range. Should have >= operator and T + uint32_t returning T.
DiffFunctor calculating the difference of two T. The result should be assignable to a uint32_t.
NBITSSize in bits of the bitmap. Range of items will be [base, base + NBITS - 1].

Member Typedef Documentation

◆ bitmap_type

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
using bitmap_type = std::array<uint32_t, NITEMS>

Constructor & Destructor Documentation

◆ BitmapRange() [1/3]

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
BitmapRange ( )
inlinenoexcept

Default constructor.

Constructs an empty range with default base.

◆ BitmapRange() [2/3]

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
BitmapRange ( base)
inlineexplicitnoexcept

Base-specific constructor.

Constructs an empty range with specified base.

Parameters
baseSpecific base value for the created range.

◆ BitmapRange() [3/3]

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
BitmapRange ( base,
uint32_t  max_bits 
)
inlinenoexcept

Range specific constructor.

Constructs an empty range with specified base and maximum bits.

Parameters
baseSpecific base value for the created range.
max_bitsSpecific maximum number of bits.

Member Function Documentation

◆ 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
itemValue to be added.
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
fromStarting value of the range to add.
toEnding value of the range to add.

◆ base() [1/3]

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
T base ( ) const
inlinenoexcept

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>
void base ( base)
inlinenoexcept

Set a new base for the range.

This method resets the range and sets a new value for its base.

Parameters
baseNew base value to set.

◆ base() [3/3]

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void base ( 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
baseNew base value to set.
max_bitsNew maximum number of bits.

◆ base_update()

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
void base_update ( 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
baseNew 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_bitsUpon return, it will contain the number of significant bits in the bitmap.
bitmapUpon return, it will contain the current value of the bitmap.
num_longs_usedUpon 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_bitsNumber of significant bits in the input bitmap.
bitmapPoints to the beginning of a uint32_t array holding the input bitmap.

◆ empty()

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
bool empty ( ) const
inlinenoexcept

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
fFunction 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
itemValue to be checked.
Returns
true if the item is present in the bitmap, false otherwise.

◆ max()

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
T max ( ) const
inlinenoexcept

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>
T min ( ) const
inlinenoexcept

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
itemValue to be removed.

Member Data Documentation

◆ base_

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
T base_
protected

Holds base value of the range.

◆ bitmap_

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
bitmap_type bitmap_
protected

Holds the bitmap values.

◆ num_bits_

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
uint32_t num_bits_
protected

Holds the highest bit set in the bitmap.

◆ range_max_

template<class T , class Diff = DiffFunction<T>, uint32_t NBITS = 256>
T range_max_
protected

Holds maximum allowed value of the range.


The documentation for this class was generated from the following file: