iceoryx_doc  1.0.1
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
iox::roudi::FixedSizeContainer< T, capacity > Class Template Reference

#include <fixed_size_container.hpp>

Public Types

using Index_t = int32_t
 
using Capacity_t = decltype(capacity)
 

Public Member 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 ()
 

Static Public Attributes

static constexpr int32_t NOT_AN_ELEMENT = -1
 

Detailed Description

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

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

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)

Member Function Documentation

◆ add()

template<typename T , uint32_t capacity = 1U>
Index_t iox::roudi::FixedSizeContainer< T, capacity >::add ( const T &  element)
inline
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

◆ operator[]()

template<typename T , uint32_t capacity = 1U>
T& iox::roudi::FixedSizeContainer< T, capacity >::operator[] ( Index_t  index)
inline
Note
access can change the underlying object, without modifying valid flag if the index is invalid than the behavior is undefined

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