fennec
Loading...
Searching...
No Matches
fennec::dynarray< TypeT, Alloc >

Wrapper for dynamically sized and allocated arrays. More...

#include <dynarray.h>

Detailed Description

template<class TypeT, class Alloc = allocator<TypeT>>
struct fennec::dynarray< TypeT, Alloc >
Property Value
stable
dynamic
homogenous
distinct
ordered
space \(O(N)\)
linear
access \(O(1)\)
find \(O(N)\)
insertion \(O(N)\)
deletion \(O(N)\)

This structure prefers shallow moves and deep copies.

Template Parameters
TypeTvalue type

Public Types

using value_t = TypeT
 Alias for the value type.
 
using alloc_t = Alloc
 Alias for the allocator type.
 

Public Member Functions

Constructors & Destructor
constexpr dynarray ()
 Default Constructor, initializes an empty allocation.
 
constexpr dynarray (const alloc_t &alloc)
 Alloc Constructor, initialize empty allocation with allocator instance.
 
constexpr dynarray (alloc_t &&alloc) noexcept
 Alloc Move Constructor, initialize empty allocation with allocator instance.
 
constexpr dynarray (size_t n)
 Sized Allocation, initializes a dynarray with n elements using the default constructor.
 
constexpr dynarray (size_t n, const alloc_t &alloc)
 Sized Allocation Alloc Constructor, initializes a dynarray with allocator alloc and n elements using the default constructor.
 
constexpr dynarray (size_t n, alloc_t &&alloc)
 Sized Allocation Alloc Move Constructor, initializes a dynarray with allocator alloc and n elements using the default constructor.
 
constexpr dynarray (size_t n, const TypeT &val)
 Sized Allocation Copy Constructor, Create an allocation of size n elements, with each element constructed using the copy constructor.
 
template<typename... ArgsT>
constexpr dynarray (size_t n, ArgsT &&...args)
 Emplace Constructor.
 
template<size_t N>
constexpr dynarray (const TypeT(&arr)[N])
 Array Copy Constructor.
 
template<size_t N>
constexpr dynarray (TypeT(&&arr)[N])
 Array Move Constructor.
 
template<typename OTypeT , class OAlloc >
constexpr dynarray (const dynarray< OTypeT, OAlloc > &conv)
 Conversion Constructor, copies elements of conv as this value_t
 
constexpr dynarray (initializer_list< value_t > l, const alloc_t &alloc=alloc_t())
 Initializer List Constructor.
 
constexpr dynarray (const dynarray &arr)
 Copy Constructor, uses the copy constructor to copy each element.
 
constexpr dynarray (dynarray &&arr) noexcept
 Move Constructor, takes ownership of the allocation.
 
constexpr ~dynarray ()
 Default Destructor, destructs all elements and frees the underlying allocation.
 
Properties
constexpr dynarrayoperator= (const dynarray &arr)
 Copy Assignment Operator.
 
constexpr dynarrayoperator= (dynarray &&arr) noexcept
 Move Assignment Operator.
 
template<size_t N>
constexpr dynarrayoperator= (const TypeT(&arr)[N])
 Array Copy Assignment Operator.
 
template<size_t N>
constexpr dynarrayoperator= (TypeT(&&arr)[N])
 Array Copy Assignment Operator.
 
constexpr size_t size () const
 
constexpr size_t capacity () const
 
constexpr bool empty () const
 
Access
constexpr TypeT & operator[] (size_t i)
 Array Access Operator.
 
constexpr const TypeT & operator[] (size_t i) const
 Array Access Operator (const)
 
constexpr TypeT & front ()
 
constexpr const TypeT & front () const
 
constexpr TypeT & back ()
 
constexpr const TypeT & back () const
 
Modifiers
constexpr void insert (size_t i, TypeT &&val)
 Move Insertion.
 
constexpr void insert (size_t i, const TypeT &val)
 Copy Insertion.
 
template<typename... ArgsT>
constexpr void emplace (size_t i, ArgsT &&...args)
 Emplace Insertion.
 
constexpr void push_back (const TypeT &val)
 Push Back Copy.
 
constexpr void push_back (TypeT &&val)
 Push Back Move.
 
template<typename... ArgsT>
constexpr void emplace_back (ArgsT...args)
 Emplace Back.
 
constexpr void pop_back ()
 Erase last element.
 
constexpr void resize (size_t n)
 Resize the dynarray, invoking the default constructor for all new elements.
 
constexpr void resize (size_t n, const TypeT &val)
 Resize the dynarray, invoking the copy constructor for all new elements.
 
constexpr void clear ()
 Clears the contents of the dynarray, destructing all elements and releasing the allocation.
 
Iteration
constexpr TypeT * begin ()
 "Iterator" Begin Function
 
constexpr TypeT * end ()
 "Iterator" End Function
 
constexpr const TypeT * begin () const
 Const "Iterator" Begin Function.
 
constexpr const TypeT * end () const
 Const "Iterator" End Function.
 

Constructor & Destructor Documentation

◆ dynarray() [1/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( const alloc_t alloc)
inlineexplicitconstexpr
Parameters
allocAn allocator object to copy, for instances where the allocator needs to be initialized with some data.

◆ dynarray() [2/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( alloc_t &&  alloc)
inlineexplicitconstexprnoexcept
Parameters
allocAn allocator object to copy, for instances where the allocator needs to be initialized with some data.

◆ dynarray() [3/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( size_t  n)
inlineexplicitconstexpr
Parameters
nThe number of elements.

◆ dynarray() [4/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( size_t  n,
const alloc_t alloc 
)
inlineconstexpr
Parameters
nThe number of elements
allocThe allocator object to copy

◆ dynarray() [5/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( size_t  n,
alloc_t &&  alloc 
)
inlineconstexpr
Parameters
nThe number of elements
allocThe allocator object to copy

◆ dynarray() [6/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( size_t  n,
const TypeT &  val 
)
inlineconstexpr
Parameters
nthe number of elements
valthe value to copy

◆ dynarray() [7/13]

template<class TypeT , class Alloc = allocator<TypeT>>
template<typename... ArgsT>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( size_t  n,
ArgsT &&...  args 
)
inlineexplicitconstexpr
Template Parameters
ArgsTA sequence of argument types
Parameters
nThe number of objects to create
argsThe arguments to create each object with

◆ dynarray() [8/13]

template<class TypeT , class Alloc = allocator<TypeT>>
template<size_t N>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( const TypeT(&)  arr[N])
inlineconstexpr
Template Parameters
NThe length of the array, automatically deduced
Parameters
arrThe array to copy

◆ dynarray() [9/13]

template<class TypeT , class Alloc = allocator<TypeT>>
template<size_t N>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( TypeT(&&)  arr[N])
inlineconstexpr
Template Parameters
NThe length of the array, automatically deduced
Parameters
arrThe array to move

◆ dynarray() [10/13]

template<class TypeT , class Alloc = allocator<TypeT>>
template<typename OTypeT , class OAlloc >
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( const dynarray< OTypeT, OAlloc > &  conv)
inlineconstexpr
Template Parameters
OTypeTThe other value type
OAllocThe other allocator type
Parameters
convThe dynarray to convert

◆ dynarray() [11/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( initializer_list< value_t l,
const alloc_t alloc = alloc_t() 
)
inlineconstexpr
Parameters
lList of elements to initialize with
allocAn allocator object to copy

◆ dynarray() [12/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( const dynarray< TypeT, Alloc > &  arr)
inlineconstexpr
Parameters
arrthe dynarray to copy

◆ dynarray() [13/13]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr fennec::dynarray< TypeT, Alloc >::dynarray ( dynarray< TypeT, Alloc > &&  arr)
inlineconstexprnoexcept
Parameters
arrthe dynarray to move

Member Function Documentation

◆ operator=() [1/4]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr dynarray & fennec::dynarray< TypeT, Alloc >::operator= ( const dynarray< TypeT, Alloc > &  arr)
inlineconstexpr
Parameters
arrthe array to copy
Returns
A dynarray after having copied each element of arr

◆ operator=() [2/4]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr dynarray & fennec::dynarray< TypeT, Alloc >::operator= ( dynarray< TypeT, Alloc > &&  arr)
inlineconstexprnoexcept
Parameters
arrthe array to move
Returns
A dynarray after having taken ownership of the contents of arr

◆ operator=() [3/4]

template<class TypeT , class Alloc = allocator<TypeT>>
template<size_t N>
constexpr dynarray & fennec::dynarray< TypeT, Alloc >::operator= ( const TypeT(&)  arr[N])
inlineconstexpr
Template Parameters
Nthe length of the array
Parameters
arrthe array to copy
Returns
A dynarray after having copied each element of arr

◆ operator=() [4/4]

template<class TypeT , class Alloc = allocator<TypeT>>
template<size_t N>
constexpr dynarray & fennec::dynarray< TypeT, Alloc >::operator= ( TypeT(&&)  arr[N])
inlineconstexpr
Template Parameters
Nthe length of the array
Parameters
arrthe array to copy
Returns
A dynarray after having moved each element of arr

◆ size()

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr size_t fennec::dynarray< TypeT, Alloc >::size ( ) const
inlineconstexpr
Returns
The size of the dynarray in elements

◆ capacity()

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr size_t fennec::dynarray< TypeT, Alloc >::capacity ( ) const
inlineconstexpr
Returns
The current capacity, in elements, of the underlying allocation

◆ empty()

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr bool fennec::dynarray< TypeT, Alloc >::empty ( ) const
inlineconstexpr
Returns
True when there are no elements active, otherwise false

◆ operator[]() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr TypeT & fennec::dynarray< TypeT, Alloc >::operator[] ( size_t  i)
inlineconstexpr
Parameters
iThe index to access
Returns
A reference to the element at index i

◆ operator[]() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr const TypeT & fennec::dynarray< TypeT, Alloc >::operator[] ( size_t  i) const
inlineconstexpr
Parameters
iThe index to access
Returns
A const qualified reference to the element at index i

◆ front() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr TypeT & fennec::dynarray< TypeT, Alloc >::front ( )
inlineconstexpr
Returns
Reference to the first element in the dynarray

◆ front() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr const TypeT & fennec::dynarray< TypeT, Alloc >::front ( ) const
inlineconstexpr
Returns
A const-qualified reference to the first element in the dynarray

◆ back() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr TypeT & fennec::dynarray< TypeT, Alloc >::back ( )
inlineconstexpr
Returns
A reference to the last element in the dynarray

◆ back() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr const TypeT & fennec::dynarray< TypeT, Alloc >::back ( ) const
inlineconstexpr
Returns
A const-qualified reference to the last element in the dynarray

◆ insert() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr void fennec::dynarray< TypeT, Alloc >::insert ( size_t  i,
TypeT &&  val 
)
inlineconstexpr
Parameters
iindex to insert at
valthe value to initialize with

◆ insert() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr void fennec::dynarray< TypeT, Alloc >::insert ( size_t  i,
const TypeT &  val 
)
inlineconstexpr
Parameters
iindex to insert at
valthe value to initialize with

◆ emplace()

template<class TypeT , class Alloc = allocator<TypeT>>
template<typename... ArgsT>
constexpr void fennec::dynarray< TypeT, Alloc >::emplace ( size_t  i,
ArgsT &&...  args 
)
inlineconstexpr
Parameters
iindex to insert at
argsArguments to construct with
Template Parameters
ArgsTArgument types

◆ push_back() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr void fennec::dynarray< TypeT, Alloc >::push_back ( const TypeT &  val)
inlineconstexpr
Parameters
valValue to initialize with

◆ push_back() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr void fennec::dynarray< TypeT, Alloc >::push_back ( TypeT &&  val)
inlineconstexpr
Parameters
valValue to initialize with

◆ emplace_back()

template<class TypeT , class Alloc = allocator<TypeT>>
template<typename... ArgsT>
constexpr void fennec::dynarray< TypeT, Alloc >::emplace_back ( ArgsT...  args)
inlineconstexpr
Template Parameters
ArgsTArgument Types
Parameters
argsArguments to construct with

◆ resize() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr void fennec::dynarray< TypeT, Alloc >::resize ( size_t  n)
inlineconstexpr
Parameters
nThe new size in elements

◆ resize() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr void fennec::dynarray< TypeT, Alloc >::resize ( size_t  n,
const TypeT &  val 
)
inlineconstexpr
Parameters
nThe new size in elements
valThe value to fill with

◆ begin() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr TypeT * fennec::dynarray< TypeT, Alloc >::begin ( )
inlineconstexpr
Returns
A pointer to the first element in the dynarray

◆ end() [1/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr TypeT * fennec::dynarray< TypeT, Alloc >::end ( )
inlineconstexpr
Returns
A pointer to the address after the last element in the dynarray

◆ begin() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr const TypeT * fennec::dynarray< TypeT, Alloc >::begin ( ) const
inlineconstexpr
Returns
A const qualified pointer to the first element in the dynarray

◆ end() [2/2]

template<class TypeT , class Alloc = allocator<TypeT>>
constexpr const TypeT * fennec::dynarray< TypeT, Alloc >::end ( ) const
inlineconstexpr
Returns
A const qualified pointer to the address after the last element in the dynarray

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