RADLib
RADical C++ application framework
RADData::RADSmallVector< T, InlineN, Alloc > Class Template Reference

Vector with InlineN elements of inline storage before heap allocation. More...

#include <RADDataStructures.h>

Public Types

using iterator = T *
 Mutable contiguous iterator. More...
 
using const_iterator = const T *
 Const contiguous iterator. More...
 

Public Member Functions

 RADSmallVector ()
 Creates an empty small vector using inline storage. More...
 
 RADSmallVector (std::initializer_list< T > values)
 Creates a small vector from initializer-list values. More...
 
 RADSmallVector (const RADSmallVector &other)
 Copies another small vector. More...
 
 RADSmallVector (RADSmallVector &&other) noexcept
 Moves another small vector. More...
 
RADSmallVectoroperator= (const RADSmallVector &other)
 Replaces this vector with a copy of other. More...
 
RADSmallVectoroperator= (RADSmallVector &&other) noexcept
 Replaces this vector by moving from other. More...
 
 ~RADSmallVector ()
 Destroys elements and heap storage, if allocated. More...
 
iterator begin () noexcept
 Returns iterator to first element. More...
 
const_iterator begin () const noexcept
 Returns const iterator to first element. More...
 
iterator end () noexcept
 Returns iterator one past the last element. More...
 
const_iterator end () const noexcept
 Returns const iterator one past the last element. More...
 
bool empty () const noexcept
 Returns true when no elements are stored. More...
 
size_t size () const noexcept
 Returns number of elements. More...
 
size_t capacity () const noexcept
 Returns current capacity, including inline capacity. More...
 
bool usingInlineStorage () const noexcept
 Returns true while storage is still inline. More...
 
T * data () noexcept
 Returns mutable contiguous storage pointer. More...
 
const T * data () const noexcept
 Returns const contiguous storage pointer. More...
 
T & operator[] (size_t index) noexcept
 Returns element at index without bounds checking. More...
 
const T & operator[] (size_t index) const noexcept
 Returns const element at index without bounds checking. More...
 
T & back () noexcept
 Returns last element; vector must not be empty. More...
 
const T & back () const noexcept
 Returns last element; vector must not be empty. More...
 
void reserve (size_t newCapacity)
 Ensures capacity is at least newCapacity. More...
 
template<typename... Args>
T & emplace_back (Args &&... args)
 Constructs an element at the end and returns it. More...
 
void push_back (const T &value)
 Appends a copy of value. More...
 
void push_back (T &&value)
 Appends value by move. More...
 
void pop_back ()
 Removes the last element when present. More...
 
void clear () noexcept
 Destroys all elements while keeping current storage. More...
 

Detailed Description

template<typename T, size_t InlineN = 8, typename Alloc = std::allocator<T>>
class RADData::RADSmallVector< T, InlineN, Alloc >

Vector with InlineN elements of inline storage before heap allocation.

Member Typedef Documentation

◆ const_iterator

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
using RADData::RADSmallVector< T, InlineN, Alloc >::const_iterator = const T*

Const contiguous iterator.

◆ iterator

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
using RADData::RADSmallVector< T, InlineN, Alloc >::iterator = T*

Mutable contiguous iterator.

Constructor & Destructor Documentation

◆ RADSmallVector() [1/4]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADData::RADSmallVector< T, InlineN, Alloc >::RADSmallVector ( )
inline

Creates an empty small vector using inline storage.

◆ RADSmallVector() [2/4]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADData::RADSmallVector< T, InlineN, Alloc >::RADSmallVector ( std::initializer_list< T >  values)
inline

Creates a small vector from initializer-list values.

◆ RADSmallVector() [3/4]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADData::RADSmallVector< T, InlineN, Alloc >::RADSmallVector ( const RADSmallVector< T, InlineN, Alloc > &  other)
inline

Copies another small vector.

◆ RADSmallVector() [4/4]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADData::RADSmallVector< T, InlineN, Alloc >::RADSmallVector ( RADSmallVector< T, InlineN, Alloc > &&  other)
inlinenoexcept

Moves another small vector.

◆ ~RADSmallVector()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADData::RADSmallVector< T, InlineN, Alloc >::~RADSmallVector ( )
inline

Destroys elements and heap storage, if allocated.

Member Function Documentation

◆ back() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
const T& RADData::RADSmallVector< T, InlineN, Alloc >::back ( ) const
inlinenoexcept

Returns last element; vector must not be empty.

◆ back() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
T& RADData::RADSmallVector< T, InlineN, Alloc >::back ( )
inlinenoexcept

Returns last element; vector must not be empty.

◆ begin() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
const_iterator RADData::RADSmallVector< T, InlineN, Alloc >::begin ( ) const
inlinenoexcept

Returns const iterator to first element.

◆ begin() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
iterator RADData::RADSmallVector< T, InlineN, Alloc >::begin ( )
inlinenoexcept

Returns iterator to first element.

◆ capacity()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
size_t RADData::RADSmallVector< T, InlineN, Alloc >::capacity ( ) const
inlinenoexcept

Returns current capacity, including inline capacity.

◆ clear()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
void RADData::RADSmallVector< T, InlineN, Alloc >::clear ( )
inlinenoexcept

Destroys all elements while keeping current storage.

◆ data() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
const T* RADData::RADSmallVector< T, InlineN, Alloc >::data ( ) const
inlinenoexcept

Returns const contiguous storage pointer.

◆ data() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
T* RADData::RADSmallVector< T, InlineN, Alloc >::data ( )
inlinenoexcept

Returns mutable contiguous storage pointer.

◆ emplace_back()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
template<typename... Args>
T& RADData::RADSmallVector< T, InlineN, Alloc >::emplace_back ( Args &&...  args)
inline

Constructs an element at the end and returns it.

◆ empty()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
bool RADData::RADSmallVector< T, InlineN, Alloc >::empty ( ) const
inlinenoexcept

Returns true when no elements are stored.

◆ end() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
const_iterator RADData::RADSmallVector< T, InlineN, Alloc >::end ( ) const
inlinenoexcept

Returns const iterator one past the last element.

◆ end() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
iterator RADData::RADSmallVector< T, InlineN, Alloc >::end ( )
inlinenoexcept

Returns iterator one past the last element.

◆ operator=() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADSmallVector& RADData::RADSmallVector< T, InlineN, Alloc >::operator= ( const RADSmallVector< T, InlineN, Alloc > &  other)
inline

Replaces this vector with a copy of other.

◆ operator=() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
RADSmallVector& RADData::RADSmallVector< T, InlineN, Alloc >::operator= ( RADSmallVector< T, InlineN, Alloc > &&  other)
inlinenoexcept

Replaces this vector by moving from other.

◆ operator[]() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
const T& RADData::RADSmallVector< T, InlineN, Alloc >::operator[] ( size_t  index) const
inlinenoexcept

Returns const element at index without bounds checking.

◆ operator[]() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
T& RADData::RADSmallVector< T, InlineN, Alloc >::operator[] ( size_t  index)
inlinenoexcept

Returns element at index without bounds checking.

◆ pop_back()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
void RADData::RADSmallVector< T, InlineN, Alloc >::pop_back ( )
inline

Removes the last element when present.

◆ push_back() [1/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
void RADData::RADSmallVector< T, InlineN, Alloc >::push_back ( const T &  value)
inline

Appends a copy of value.

◆ push_back() [2/2]

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
void RADData::RADSmallVector< T, InlineN, Alloc >::push_back ( T &&  value)
inline

Appends value by move.

◆ reserve()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
void RADData::RADSmallVector< T, InlineN, Alloc >::reserve ( size_t  newCapacity)
inline

Ensures capacity is at least newCapacity.

◆ size()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
size_t RADData::RADSmallVector< T, InlineN, Alloc >::size ( ) const
inlinenoexcept

Returns number of elements.

◆ usingInlineStorage()

template<typename T , size_t InlineN = 8, typename Alloc = std::allocator<T>>
bool RADData::RADSmallVector< T, InlineN, Alloc >::usingInlineStorage ( ) const
inlinenoexcept

Returns true while storage is still inline.


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