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

Contiguous dynamic array optimized for RADLib hot paths. More...

#include <RADDataStructures.h>

Public Types

using value_type = T
 Stored value type. More...
 
using allocator_type = Alloc
 Allocator type. More...
 
using size_type = size_t
 Unsigned size type. More...
 
using reference = T &
 Mutable reference type. More...
 
using const_reference = const T &
 Const reference type. More...
 
using pointer = T *
 Mutable pointer type. More...
 
using const_pointer = const T *
 Const pointer type. More...
 
using iterator = T *
 Mutable contiguous iterator. More...
 
using const_iterator = const T *
 Const contiguous iterator. More...
 

Public Member Functions

 RADVector ()=default
 Creates an empty vector. More...
 
 RADVector (size_t count, const T &value=T())
 Creates count copies of value. More...
 
 RADVector (std::initializer_list< T > values)
 Creates a vector from initializer-list values. More...
 
 RADVector (const RADVector &other)
 Copies another vector. More...
 
 RADVector (RADVector &&other) noexcept
 Moves another vector without moving individual elements when possible. More...
 
RADVectoroperator= (const RADVector &other)
 Replaces this vector with a copy of other. More...
 
RADVectoroperator= (RADVector &&other) noexcept
 Replaces this vector by taking other's storage. More...
 
 ~RADVector ()
 Destroys all elements and releases owned storage. More...
 
iterator begin () noexcept
 Returns iterator to first element. More...
 
const_iterator begin () const noexcept
 Returns const iterator to first element. More...
 
const_iterator cbegin () 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...
 
const_iterator cend () const noexcept
 Returns const iterator one past the last element. More...
 
bool empty () const noexcept
 Returns true when the vector contains no elements. More...
 
size_t size () const noexcept
 Returns the number of constructed elements. More...
 
size_t capacity () const noexcept
 Returns allocated element capacity. 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 & at (size_t index)
 Returns element at index or throws std::out_of_range. More...
 
const T & at (size_t index) const
 Returns const element at index or throws std::out_of_range. More...
 
T & front () noexcept
 Returns first element; vector must not be empty. More...
 
const T & front () const noexcept
 Returns first element; vector must not be empty. 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...
 
void shrink_to_fit ()
 Releases unused capacity when possible. More...
 
void resize (size_t newSize)
 Resizes with value-initialized new elements. More...
 
void resize (size_t newSize, const T &value)
 Resizes with copies of value for new elements. 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...
 
iterator erase (const_iterator position)
 Removes the element at position and returns the next iterator. More...
 
void clear () noexcept
 Destroys all elements while keeping capacity. More...
 

Detailed Description

template<typename T, typename Alloc = std::allocator<T>>
class RADData::RADVector< T, Alloc >

Contiguous dynamic array optimized for RADLib hot paths.

Member Typedef Documentation

◆ allocator_type

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::allocator_type = Alloc

Allocator type.

◆ const_iterator

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::const_iterator = const T*

Const contiguous iterator.

◆ const_pointer

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::const_pointer = const T*

Const pointer type.

◆ const_reference

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::const_reference = const T&

Const reference type.

◆ iterator

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::iterator = T*

Mutable contiguous iterator.

◆ pointer

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::pointer = T*

Mutable pointer type.

◆ reference

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::reference = T&

Mutable reference type.

◆ size_type

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::size_type = size_t

Unsigned size type.

◆ value_type

template<typename T , typename Alloc = std::allocator<T>>
using RADData::RADVector< T, Alloc >::value_type = T

Stored value type.

Constructor & Destructor Documentation

◆ RADVector() [1/5]

template<typename T , typename Alloc = std::allocator<T>>
RADData::RADVector< T, Alloc >::RADVector ( )
default

Creates an empty vector.

◆ RADVector() [2/5]

template<typename T , typename Alloc = std::allocator<T>>
RADData::RADVector< T, Alloc >::RADVector ( size_t  count,
const T &  value = T() 
)
inlineexplicit

Creates count copies of value.

◆ RADVector() [3/5]

template<typename T , typename Alloc = std::allocator<T>>
RADData::RADVector< T, Alloc >::RADVector ( std::initializer_list< T >  values)
inline

Creates a vector from initializer-list values.

◆ RADVector() [4/5]

template<typename T , typename Alloc = std::allocator<T>>
RADData::RADVector< T, Alloc >::RADVector ( const RADVector< T, Alloc > &  other)
inline

Copies another vector.

◆ RADVector() [5/5]

template<typename T , typename Alloc = std::allocator<T>>
RADData::RADVector< T, Alloc >::RADVector ( RADVector< T, Alloc > &&  other)
inlinenoexcept

Moves another vector without moving individual elements when possible.

◆ ~RADVector()

template<typename T , typename Alloc = std::allocator<T>>
RADData::RADVector< T, Alloc >::~RADVector ( )
inline

Destroys all elements and releases owned storage.

Member Function Documentation

◆ at() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
T& RADData::RADVector< T, Alloc >::at ( size_t  index)
inline

Returns element at index or throws std::out_of_range.

◆ at() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
const T& RADData::RADVector< T, Alloc >::at ( size_t  index) const
inline

Returns const element at index or throws std::out_of_range.

◆ back() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
const T& RADData::RADVector< T, Alloc >::back ( ) const
inlinenoexcept

Returns last element; vector must not be empty.

◆ back() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
T& RADData::RADVector< T, Alloc >::back ( )
inlinenoexcept

Returns last element; vector must not be empty.

◆ begin() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
const_iterator RADData::RADVector< T, Alloc >::begin ( ) const
inlinenoexcept

Returns const iterator to first element.

◆ begin() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
iterator RADData::RADVector< T, Alloc >::begin ( )
inlinenoexcept

Returns iterator to first element.

◆ capacity()

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

Returns allocated element capacity.

◆ cbegin()

template<typename T , typename Alloc = std::allocator<T>>
const_iterator RADData::RADVector< T, Alloc >::cbegin ( ) const
inlinenoexcept

Returns const iterator to first element.

◆ cend()

template<typename T , typename Alloc = std::allocator<T>>
const_iterator RADData::RADVector< T, Alloc >::cend ( ) const
inlinenoexcept

Returns const iterator one past the last element.

◆ clear()

template<typename T , typename Alloc = std::allocator<T>>
void RADData::RADVector< T, Alloc >::clear ( )
inlinenoexcept

Destroys all elements while keeping capacity.

◆ data() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
const T* RADData::RADVector< T, Alloc >::data ( ) const
inlinenoexcept

Returns const contiguous storage pointer.

◆ data() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
T* RADData::RADVector< T, Alloc >::data ( )
inlinenoexcept

Returns mutable contiguous storage pointer.

◆ emplace_back()

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

Constructs an element at the end and returns it.

◆ empty()

template<typename T , typename Alloc = std::allocator<T>>
bool RADData::RADVector< T, Alloc >::empty ( ) const
inlinenoexcept

Returns true when the vector contains no elements.

◆ end() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
const_iterator RADData::RADVector< T, Alloc >::end ( ) const
inlinenoexcept

Returns const iterator one past the last element.

◆ end() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
iterator RADData::RADVector< T, Alloc >::end ( )
inlinenoexcept

Returns iterator one past the last element.

◆ erase()

template<typename T , typename Alloc = std::allocator<T>>
iterator RADData::RADVector< T, Alloc >::erase ( const_iterator  position)
inline

Removes the element at position and returns the next iterator.

◆ front() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
const T& RADData::RADVector< T, Alloc >::front ( ) const
inlinenoexcept

Returns first element; vector must not be empty.

◆ front() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
T& RADData::RADVector< T, Alloc >::front ( )
inlinenoexcept

Returns first element; vector must not be empty.

◆ operator=() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
RADVector& RADData::RADVector< T, Alloc >::operator= ( const RADVector< T, Alloc > &  other)
inline

Replaces this vector with a copy of other.

◆ operator=() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
RADVector& RADData::RADVector< T, Alloc >::operator= ( RADVector< T, Alloc > &&  other)
inlinenoexcept

Replaces this vector by taking other's storage.

◆ operator[]() [1/2]

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

Returns const element at index without bounds checking.

◆ operator[]() [2/2]

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

Returns element at index without bounds checking.

◆ pop_back()

template<typename T , typename Alloc = std::allocator<T>>
void RADData::RADVector< T, Alloc >::pop_back ( )
inline

Removes the last element when present.

◆ push_back() [1/2]

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

Appends a copy of value.

◆ push_back() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
void RADData::RADVector< T, Alloc >::push_back ( T &&  value)
inline

Appends value by move.

◆ reserve()

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

Ensures capacity is at least newCapacity.

◆ resize() [1/2]

template<typename T , typename Alloc = std::allocator<T>>
void RADData::RADVector< T, Alloc >::resize ( size_t  newSize)
inline

Resizes with value-initialized new elements.

◆ resize() [2/2]

template<typename T , typename Alloc = std::allocator<T>>
void RADData::RADVector< T, Alloc >::resize ( size_t  newSize,
const T &  value 
)
inline

Resizes with copies of value for new elements.

◆ shrink_to_fit()

template<typename T , typename Alloc = std::allocator<T>>
void RADData::RADVector< T, Alloc >::shrink_to_fit ( )
inline

Releases unused capacity when possible.

◆ size()

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

Returns the number of constructed elements.


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