Skip to content



#include <fixed_size_container.hpp>

Public Types🔗

using int32_t Index_t
using decltype(capacity) Capacity_t

Public Functions🔗

Index_t add(const T & element)
void remove(Index_t index)
T & operator[](Index_t index)
T * get(Index_t index)
size_t size()

Public Attributes🔗

constexpr int32_t NOT_AN_ELEMENT

Detailed Description🔗

template <typename T ,
uint32_t capacity =1U>
class iox::roudi::FixedSizeContainer;

Attention: no bounds checking during access for efficiency (as in STL containers) access to indices < 0 or >= capacity is undefined behaviour (most likely a segmentation fault)

allows allocating a predefined capacity of T objects on the stack and using there pointers outside (pointers stay valid until object is removed from theFixedSizeContainer) therefore we avoid heap allocation but we can still use pointers to objects for efficient update/passing until we exhaust the fixed size container

Public Types Documentation🔗

using Index_t🔗

using iox::roudi::FixedSizeContainer< T, capacity >::Index_t =  int32_t;

using Capacity_t🔗

using iox::roudi::FixedSizeContainer< T, capacity >::Capacity_t =  decltype(capacity);

Public Functions Documentation🔗

function FixedSizeContainer🔗

inline FixedSizeContainer()

function add🔗

inline Index_t add(
    const T & element

Note: returns index or -1 if element could not be added a successful add returns an arbitrary index which can be non consecutive for consecutive adds

function remove🔗

inline void remove(
    Index_t index

function operator[]🔗

inline T & operator[](
    Index_t index

Note: access can change the underlying object, without modifying valid flag if the index is invalid than the behavior is undefined

function get🔗

inline T * get(
    Index_t index

function size🔗

inline size_t size()

Public Attributes Documentation🔗

variable NOT_AN_ELEMENT🔗

static constexpr int32_t NOT_AN_ELEMENT = -1;

Updated on 26 April 2021 at 15:31:02 CEST