Safe DDS
eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS > Class Template Reference

Template class to provide a set of utils for bitmaps. More...

#include <BitmapFunctionality.hpp>

Public Types

using bitmap_type = Array< uint32_t, NITEMS >
 Alias to improve readability. More...
 

Static Public Member Functions

static bool empty (const Bitmap< T, NITEMS > &bitmap) noexcept
 Check if the bitmap is empty. More...
 
static ReturnCode max (const Bitmap< T, NITEMS > &bitmap, T &result) noexcept
 Get the maximum value in the bitmap. More...
 
static ReturnCode min (const Bitmap< T, NITEMS > &bitmap, T &result) noexcept
 Get the minimum value in the bitmap. More...
 
static ReturnCode min_max (const Bitmap< T, NITEMS > &bitmap, T &min_value, T &max_value) noexcept
 Get the minimum and maximum values in the bitmap. More...
 
static bool is_set (const Bitmap< T, NITEMS > &bitmap, const T &item) noexcept
 Check if an item is set in the bitmap. More...
 
static void add (Bitmap< T, NITEMS > &bitmap, const T &item) noexcept
 Add an item to the bitmap. More...
 
static void add_range (Bitmap< T, NITEMS > &bitmap, const T &from, const T &to) noexcept
 Add a range of items to the bitmap. More...
 
static void merge (Bitmap< T, NITEMS > &bitmap_merged, const Bitmap< T, NITEMS > &bitmap) noexcept
 Merge two bitmaps. More...
 
static void remove (Bitmap< T, NITEMS > &bitmap, const T &item) noexcept
 Removes an element from the bitmap. More...
 
static void remove_all (Bitmap< T, NITEMS > &bitmap) noexcept
 Removes all elements from the bitmap. More...
 
static void remove_range (Bitmap< T, NITEMS > &bitmap, const T &from, const T &to) noexcept
 Removes a set of consecutive elements from the bitmap. More...
 
static void base (Bitmap< T, NITEMS > &bitmap, const T &new_base) noexcept
 Set a new base for the range. More...
 
static void base_update (Bitmap< T, NITEMS > &bitmap, const T &new_base) noexcept
 Set a new base for the range, keeping old values where possible. More...
 
static uint32_t count (const Bitmap< T, NITEMS > &bitmap) noexcept
 Counts the number of bits set in the bitmap. More...
 

Static Public Attributes

static const uint32_t NITEMS = (NBITS + portable::BITS_IN_LONG - 1) / portable::BITS_IN_LONG
 Number of items. More...
 

Detailed Description

template<class T, typename BitmapHelper, uint32_t NBITS = BITMAP_BIT_SIZE>
class eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >

Template class to provide a set of utils for bitmaps.

Member Typedef Documentation

◆ bitmap_type

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
using eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::bitmap_type = Array<uint32_t, NITEMS>

Alias to improve readability.

Member Function Documentation

◆ add()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::add ( Bitmap< T, NITEMS > &  bitmap,
const T &  item 
)
inlinestaticnoexcept

Add an item to the bitmap.

Parameters
bitmapBitmap to modify.
itemValue to add.

◆ add_range()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::add_range ( Bitmap< T, NITEMS > &  bitmap,
const T &  from,
const T &  to 
)
inlinestaticnoexcept

Add a range of items to the bitmap.

Parameters
bitmapBitmap to modify.
fromStarting value of the range to add (Will be added).
toEnding value of the range to add.

◆ base()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::base ( Bitmap< T, NITEMS > &  bitmap,
const T &  new_base 
)
inlinestaticnoexcept

Set a new base for the range.

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

Parameters
bitmapBitmap to modify.
new_baseNew base value to set.

◆ base_update()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::base_update ( Bitmap< T, NITEMS > &  bitmap,
const T &  new_base 
)
inlinestaticnoexcept

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
bitmapBitmap to modify.
new_baseNew base value to set.

◆ count()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static uint32_t eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::count ( const Bitmap< T, NITEMS > &  bitmap)
inlinestaticnoexcept

Counts the number of bits set in the bitmap.

Parameters
bitmapBitmap to count.
Returns
uint32_t Number of bits set in the bitmap.

◆ empty()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static bool eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::empty ( const Bitmap< T, NITEMS > &  bitmap)
inlinestaticnoexcept

Check if the bitmap is empty.

Parameters
bitmapBitmap to check.
Returns
true if the bitmap is empty, false otherwise.

◆ is_set()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static bool eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::is_set ( const Bitmap< T, NITEMS > &  bitmap,
const T &  item 
)
inlinestaticnoexcept

Check if an item is set in the bitmap.

Parameters
bitmapBitmap to check.
itemValue to check.
Returns
true if the item is set, false otherwise.

◆ max()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static ReturnCode eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::max ( const Bitmap< T, NITEMS > &  bitmap,
T &  result 
)
inlinestaticnoexcept

Get the maximum value in the bitmap.

Parameters
bitmapBitmap to check.
resultMaximum value in the bitmap.
Returns
ReturnCode::OK if the maximum value is found, ReturnCode::CONTAINER_BITMAP_IS_EMPTY otherwise.

◆ merge()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::merge ( Bitmap< T, NITEMS > &  bitmap_merged,
const Bitmap< T, NITEMS > &  bitmap 
)
inlinestaticnoexcept

Merge two bitmaps.

Parameters
bitmap_mergedBitmap to merge into.
bitmapBitmap to merge from.

◆ min()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static ReturnCode eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::min ( const Bitmap< T, NITEMS > &  bitmap,
T &  result 
)
inlinestaticnoexcept

Get the minimum value in the bitmap.

Parameters
bitmapBitmap to check.
resultMinimum value in the bitmap.
Returns
ReturnCode::OK if the minimum value is found, ReturnCode::CONTAINER_BITMAP_IS_EMPTY otherwise.

◆ min_max()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static ReturnCode eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::min_max ( const Bitmap< T, NITEMS > &  bitmap,
T &  min_value,
T &  max_value 
)
inlinestaticnoexcept

Get the minimum and maximum values in the bitmap.

Parameters
bitmapBitmap to check.
min_valueMinimum value in the bitmap.
max_valueMaximum value in the bitmap.
Returns
ReturnCode::OK if the minimum and maximum values are found, ReturnCode::CONTAINER_BITMAP_IS_EMPTY otherwise.

◆ remove()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::remove ( Bitmap< T, NITEMS > &  bitmap,
const T &  item 
)
inlinestaticnoexcept

Removes an element from the bitmap.

Parameters
bitmapBitmap to remove the element from.
itemValue to be removed.

◆ remove_all()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::remove_all ( Bitmap< T, NITEMS > &  bitmap)
inlinestaticnoexcept

Removes all elements from the bitmap.

Parameters
bitmapBitmap to remove all elements from.

◆ remove_range()

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
static void eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::remove_range ( Bitmap< T, NITEMS > &  bitmap,
const T &  from,
const T &  to 
)
inlinestaticnoexcept

Removes a set of consecutive elements from the bitmap.

Removes all elements in the [from, to) range. Equivalent to for(T i = from; i < to; i++) remove(i);

Parameters
bitmapBitmap to remove the range from.
fromStarting value of the range to remove (Will be removed).
toEnding value of the range to remove.

Member Data Documentation

◆ NITEMS

template<class T , typename BitmapHelper , uint32_t NBITS = BITMAP_BIT_SIZE>
const uint32_t eprosima::safedds::memory::container::BitmapFunctionality< T, BitmapHelper, NBITS >::NITEMS = (NBITS + portable::BITS_IN_LONG - 1) / portable::BITS_IN_LONG
static

Number of items.


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