BioDynaMo  v1.05.119-a4ff3934
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
bdm::InlineVector< T, N > Class Template Referencefinal

#include <inline_vector.h>

Classes

struct  Iterator
 

Public Types

using value_type = T
 
using iterator = typename InlineVector::template Iterator< T, InlineVector >
 
using const_iterator = typename InlineVector::template Iterator< const T, const InlineVector >
 

Public Member Functions

 InlineVector (TRootIOCtor *io_ctor)
 
 InlineVector ()=default
 
 InlineVector (const InlineVector< T, N > &other)
 
 InlineVector (InlineVector< T, N > &&other) noexcept
 
 ~InlineVector ()
 
uint16_t capacity () const
 
void clear ()
 
void reserve (uint16_t new_capacity)
 
uint16_t size () const
 returns the number of elements in this container More...
 
void push_back (const T &element)
 
iterator erase (const iterator &it)
 
std::vector< T > make_std_vector () const
 
InlineVector< T, N > & operator= (const InlineVector< T, N > &other)
 
InlineVector< T, N > & operator= (InlineVector< T, N > &&other) noexcept
 
T & operator[] (uint16_t index)
 
const T & operator[] (uint16_t index) const
 
bool operator== (const InlineVector< T, N > &other) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Private Member Functions

uint16_t HeapSize () const
 
 BDM_CLASS_DEF_NV (InlineVector, 2)
 

Private Attributes

std::array< T, N > data_
 
uint16_t size_ = 0
 
uint16_t heap_capacity_ = 0
 
T * heap_data_ = nullptr
 

Static Private Attributes

static constexpr float kGrowFactor = 1.5
 

Friends

std::ostream & operator<< (std::ostream &out, const InlineVector< T, N > &other)
 

Detailed Description

template<typename T, uint16_t N>
class bdm::InlineVector< T, N >

This contains stores up to N elements without heap allocations If further elements are added elements are stored on the heap Container grows in a geometric sequence Elements are contiguous in memory except the transition from internal to heap allocated memory (between index N-1 and N) This container is optimized for minimal overhead. Therefore, it can only store 65535 elements.

Definition at line 49 of file inline_vector.h.

Member Typedef Documentation

◆ const_iterator

template<typename T , uint16_t N>
using bdm::InlineVector< T, N >::const_iterator = typename InlineVector::template Iterator<const T, const InlineVector>

Definition at line 155 of file inline_vector.h.

◆ iterator

template<typename T , uint16_t N>
using bdm::InlineVector< T, N >::iterator = typename InlineVector::template Iterator<T, InlineVector>

Definition at line 153 of file inline_vector.h.

◆ value_type

template<typename T , uint16_t N>
using bdm::InlineVector< T, N >::value_type = T

Definition at line 152 of file inline_vector.h.

Constructor & Destructor Documentation

◆ InlineVector() [1/4]

template<typename T , uint16_t N>
bdm::InlineVector< T, N >::InlineVector ( TRootIOCtor *  io_ctor)
inlineexplicit

Definition at line 157 of file inline_vector.h.

◆ InlineVector() [2/4]

template<typename T , uint16_t N>
bdm::InlineVector< T, N >::InlineVector ( )
default

◆ InlineVector() [3/4]

template<typename T , uint16_t N>
bdm::InlineVector< T, N >::InlineVector ( const InlineVector< T, N > &  other)
inline

Definition at line 160 of file inline_vector.h.

◆ InlineVector() [4/4]

template<typename T , uint16_t N>
bdm::InlineVector< T, N >::InlineVector ( InlineVector< T, N > &&  other)
inlinenoexcept

Definition at line 170 of file inline_vector.h.

◆ ~InlineVector()

template<typename T , uint16_t N>
bdm::InlineVector< T, N >::~InlineVector ( )
inline

Definition at line 178 of file inline_vector.h.

Member Function Documentation

◆ BDM_CLASS_DEF_NV()

template<typename T , uint16_t N>
bdm::InlineVector< T, N >::BDM_CLASS_DEF_NV ( InlineVector< T, N >  ,
 
)
private

◆ begin() [1/2]

template<typename T , uint16_t N>
iterator bdm::InlineVector< T, N >::begin ( )
inline

Definition at line 344 of file inline_vector.h.

◆ begin() [2/2]

template<typename T , uint16_t N>
const_iterator bdm::InlineVector< T, N >::begin ( ) const
inline

Definition at line 346 of file inline_vector.h.

◆ capacity()

template<typename T , uint16_t N>
uint16_t bdm::InlineVector< T, N >::capacity ( ) const
inline

Returns the number of elements that the container has currently allocated space for.

Definition at line 187 of file inline_vector.h.

◆ clear()

template<typename T , uint16_t N>
void bdm::InlineVector< T, N >::clear ( )
inline

Removes all elements from the container. Leaves capacity() unchanged.

Definition at line 191 of file inline_vector.h.

◆ end() [1/2]

template<typename T , uint16_t N>
iterator bdm::InlineVector< T, N >::end ( )
inline

Definition at line 345 of file inline_vector.h.

◆ end() [2/2]

template<typename T , uint16_t N>
const_iterator bdm::InlineVector< T, N >::end ( ) const
inline

Definition at line 347 of file inline_vector.h.

◆ erase()

template<typename T , uint16_t N>
iterator bdm::InlineVector< T, N >::erase ( const iterator it)
inline

Definition at line 240 of file inline_vector.h.

◆ HeapSize()

template<typename T , uint16_t N>
uint16_t bdm::InlineVector< T, N >::HeapSize ( ) const
inlineprivate

Definition at line 356 of file inline_vector.h.

◆ make_std_vector()

template<typename T , uint16_t N>
std::vector<T> bdm::InlineVector< T, N >::make_std_vector ( ) const
inline

Definition at line 261 of file inline_vector.h.

◆ operator=() [1/2]

template<typename T , uint16_t N>
InlineVector<T, N>& bdm::InlineVector< T, N >::operator= ( const InlineVector< T, N > &  other)
inline

Definition at line 269 of file inline_vector.h.

◆ operator=() [2/2]

template<typename T , uint16_t N>
InlineVector<T, N>& bdm::InlineVector< T, N >::operator= ( InlineVector< T, N > &&  other)
inlinenoexcept

Definition at line 287 of file inline_vector.h.

◆ operator==()

template<typename T , uint16_t N>
bool bdm::InlineVector< T, N >::operator== ( const InlineVector< T, N > &  other) const
inline

Definition at line 315 of file inline_vector.h.

◆ operator[]() [1/2]

template<typename T , uint16_t N>
T& bdm::InlineVector< T, N >::operator[] ( uint16_t  index)
inline

Definition at line 299 of file inline_vector.h.

◆ operator[]() [2/2]

template<typename T , uint16_t N>
const T& bdm::InlineVector< T, N >::operator[] ( uint16_t  index) const
inline

Definition at line 307 of file inline_vector.h.

◆ push_back()

template<typename T , uint16_t N>
void bdm::InlineVector< T, N >::push_back ( const T &  element)
inline

adds elements to this container and allocates additional memory on the heap if required

Definition at line 219 of file inline_vector.h.

◆ reserve()

template<typename T , uint16_t N>
void bdm::InlineVector< T, N >::reserve ( uint16_t  new_capacity)
inline

Increase the capacity of the container to a value that's greater or equal to new_capacity. If new_cap is greater than the current capacity(), new storage is allocated, otherwise the method does nothing.

If new_cap is greater than capacity(), all iterators and references, including the past-the-end iterator, are invalidated. Otherwise, no iterators or references are invalidated.

Definition at line 202 of file inline_vector.h.

◆ size()

template<typename T , uint16_t N>
uint16_t bdm::InlineVector< T, N >::size ( ) const
inline

returns the number of elements in this container

Definition at line 215 of file inline_vector.h.

Friends And Related Function Documentation

◆ operator<<

template<typename T , uint16_t N>
std::ostream& operator<< ( std::ostream &  out,
const InlineVector< T, N > &  other 
)
friend

Definition at line 336 of file inline_vector.h.

Member Data Documentation

◆ data_

template<typename T , uint16_t N>
std::array<T, N> bdm::InlineVector< T, N >::data_
private

Definition at line 351 of file inline_vector.h.

◆ heap_capacity_

template<typename T , uint16_t N>
uint16_t bdm::InlineVector< T, N >::heap_capacity_ = 0
private

Definition at line 353 of file inline_vector.h.

◆ heap_data_

template<typename T , uint16_t N>
T* bdm::InlineVector< T, N >::heap_data_ = nullptr
private

Definition at line 354 of file inline_vector.h.

◆ kGrowFactor

template<typename T , uint16_t N>
constexpr float bdm::InlineVector< T, N >::kGrowFactor = 1.5
staticconstexprprivate

Definition at line 350 of file inline_vector.h.

◆ size_

template<typename T , uint16_t N>
uint16_t bdm::InlineVector< T, N >::size_ = 0
private

Definition at line 352 of file inline_vector.h.


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