Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::darr_ext< T, N, Allocator > Class Template Reference

Array of elements of type. More...

#include <darray_ext_impl.h>

Public Types

using value_type = T
 Element type stored by the container.
 
using reference = T &
 Mutable element reference type.
 
using const_reference = const T &
 Read-only element reference type.
 
using pointer = T *
 Mutable element pointer type.
 
using const_pointer = const T *
 Read-only element pointer type.
 
using view_policy = mem::data_view_policy_aos< T >
 Data-layout access policy used by the container.
 
using difference_type = darr_ext_detail::difference_type
 Type used for iterator differences.
 
using size_type = darr_ext_detail::size_type
 Unsigned type used for sizes and indices.
 
using iterator = pointer
 Mutable random-access iterator type.
 
using const_iterator = const_pointer
 Read-only random-access iterator type.
 
using iterator_category = core::random_access_iterator_tag
 Iterator category exposed by the container.
 

Public Member Functions

 darr_ext (core::zero_t) noexcept
 Constructs a value-initialized container.
 
 darr_ext (size_type count, const_reference value)
 Constructs a container with copies of a value.
 
 darr_ext (size_type count)
 Constructs a container with the requested number of value-initialized elements.
 
template<typename InputIt >
 darr_ext (InputIt first, InputIt last)
 Constructs a container from an iterator range.
 
 darr_ext (std::initializer_list< T > il)
 Constructs a container from an initializer list.
 
 darr_ext (const darr_ext &other)
 Copy-constructs a container.
 
 darr_ext (darr_ext &&other) noexcept
 Move-constructs a container.
 
darr_extoperator= (std::initializer_list< T > il)
 Replaces the elements from an initializer list.
 
darr_extoperator= (const darr_ext &other)
 Copy-assigns the container.
 
darr_extoperator= (darr_ext &&other) noexcept
 Move-assigns the container.
 
GAIA_NODISCARD pointer data () noexcept
 Returns a pointer to the element storage.
 
GAIA_NODISCARD const_pointer data () const noexcept
 Returns a pointer to the element storage.
 
GAIA_NODISCARD decltype(autooperator[] (size_type pos) noexcept
 Accesses an element without bounds checking in optimized builds.
 
GAIA_NODISCARD decltype(autooperator[] (size_type pos) const noexcept
 Accesses an element without bounds checking in optimized builds.
 
void reserve (size_type cap)
 Ensures storage for at least the requested number of elements.
 
void resize (size_type count)
 Changes the number of elements.
 
void resize (size_type count, const_reference value)
 Changes the size and initializes new elements from a value.
 
void push_back (const T &arg)
 Appends an element.
 
void push_back (T &&arg)
 Appends an element.
 
template<typename... Args>
decltype(autoemplace_back (Args &&... args)
 Constructs and appends an element.
 
void pop_back () noexcept
 Removes the last element.
 
iterator insert (iterator pos, const T &arg)
 Insert the element to the position given by iterator pos.
 
iterator insert (iterator pos, T &&arg)
 Insert the element to the position given by iterator pos.
 
iterator erase (iterator pos) noexcept
 Removes the element at pos.
 
iterator erase (iterator first, iterator last) noexcept
 Removes the elements in the range [first, last)
 
void clear () noexcept
 Removes all elements.
 
void shrink_to_fit ()
 Reduces allocated storage to match the current size when possible.
 
template<typename Func >
auto retain (Func &&func) noexcept
 Removes all elements that fail the predicate.
 
GAIA_NODISCARD size_type size () const noexcept
 Returns the number of elements.
 
GAIA_NODISCARD bool empty () const noexcept
 Checks whether the container has no elements.
 
GAIA_NODISCARD size_type capacity () const noexcept
 Returns the number of elements that fit without reallocation.
 
GAIA_NODISCARD size_type max_size () const noexcept
 Returns the maximum number of elements supported by this container.
 
GAIA_NODISCARD decltype(autofront () noexcept
 Accesses the first element.
 
GAIA_NODISCARD decltype(autofront () const noexcept
 Accesses the first element.
 
GAIA_NODISCARD decltype(autoback () noexcept
 Accesses the last element.
 
GAIA_NODISCARD decltype(autoback () const noexcept
 Accesses the last element.
 
GAIA_NODISCARD auto begin () noexcept
 Returns an iterator to the first element.
 
GAIA_NODISCARD auto begin () const noexcept
 Returns an iterator to the first element.
 
GAIA_NODISCARD auto cbegin () const noexcept
 Returns a read-only iterator to the first element.
 
GAIA_NODISCARD auto rbegin () noexcept
 Returns a reverse traversal iterator to the last element.
 
GAIA_NODISCARD auto rbegin () const noexcept
 Returns a reverse traversal iterator to the last element.
 
GAIA_NODISCARD auto crbegin () const noexcept
 Returns a read-only reverse traversal iterator to the last element.
 
GAIA_NODISCARD auto end () noexcept
 Returns an iterator one past the last element.
 
GAIA_NODISCARD auto end () const noexcept
 Returns an iterator one past the last element.
 
GAIA_NODISCARD auto cend () const noexcept
 Returns a read-only iterator one past the last element.
 
GAIA_NODISCARD auto rend () noexcept
 Returns the reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD auto rend () const noexcept
 Returns the reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD auto crend () const noexcept
 Returns the read-only reverse traversal sentinel preceding the first element.
 
GAIA_NODISCARD bool operator== (const darr_ext &other) const noexcept
 Compares two containers element by element.
 
GAIA_NODISCARD constexpr bool operator!= (const darr_ext &other) const noexcept
 Checks whether two containers differ.
 

Static Public Attributes

static constexpr size_t value_size = sizeof(T)
 Size of one element in bytes.
 
static constexpr size_type extent = N
 Fixed capacity of the container.
 
static constexpr uint32_t allocated_bytes = view_policy::get_min_byte_size(0, N)
 Number of bytes reserved by the inline storage.
 

Detailed Description

template<typename T, darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
class gaia::cnt::darr_ext< T, N, Allocator >

Array of elements of type.

Template Parameters
Tallocated on heap or stack. Stack capacity is
Nelements. If the number of elements is bellow
Nthe stack storage is used. If the number of elements is above
Nthe heap storage is used. Interface compatiblity with std::vector and std::array where it matters.

Constructor & Destructor Documentation

◆ darr_ext() [1/6]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
gaia::cnt::darr_ext< T, N, Allocator >::darr_ext ( size_type  count,
const_reference  value 
)
inline

Constructs a container with copies of a value.

Parameters
countNumber of elements.
valueValue assigned to each new element.

◆ darr_ext() [2/6]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
gaia::cnt::darr_ext< T, N, Allocator >::darr_ext ( size_type  count)
inline

Constructs a container with the requested number of value-initialized elements.

Parameters
countNumber of elements.

◆ darr_ext() [3/6]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
template<typename InputIt >
gaia::cnt::darr_ext< T, N, Allocator >::darr_ext ( InputIt  first,
InputIt  last 
)
inline

Constructs a container from an iterator range.

Template Parameters
InputItInput iterator type.
Parameters
firstIterator to the first source element.
lastIterator one past the last source element.

◆ darr_ext() [4/6]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
gaia::cnt::darr_ext< T, N, Allocator >::darr_ext ( std::initializer_list< T il)
inline

Constructs a container from an initializer list.

Parameters
ilInitializer list supplying the elements.

◆ darr_ext() [5/6]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
gaia::cnt::darr_ext< T, N, Allocator >::darr_ext ( const darr_ext< T, N, Allocator > &  other)
inline

Copy-constructs a container.

Parameters
otherContainer to copy or move from.

◆ darr_ext() [6/6]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
gaia::cnt::darr_ext< T, N, Allocator >::darr_ext ( darr_ext< T, N, Allocator > &&  other)
inlinenoexcept

Move-constructs a container.

Parameters
otherContainer to copy or move from.

Member Function Documentation

◆ back() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::back ( ) const
inlinenoexcept

Accesses the last element.

Returns
Reference to the last element.

◆ back() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::back ( )
inlinenoexcept

Accesses the last element.

Returns
Reference to the last element.

◆ begin() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::begin ( ) const
inlinenoexcept

Returns an iterator to the first element.

Returns
Iterator to the first element.

◆ begin() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::begin ( )
inlinenoexcept

Returns an iterator to the first element.

Returns
Iterator to the first element.

◆ capacity()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD size_type gaia::cnt::darr_ext< T, N, Allocator >::capacity ( ) const
inlinenoexcept

Returns the number of elements that fit without reallocation.

Returns
Current element capacity.

◆ cbegin()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::cbegin ( ) const
inlinenoexcept

Returns a read-only iterator to the first element.

Returns
Iterator to the first element.

◆ cend()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::cend ( ) const
inlinenoexcept

Returns a read-only iterator one past the last element.

Returns
Iterator one past the last element.

◆ crbegin()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::crbegin ( ) const
inlinenoexcept

Returns a read-only reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ crend()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::crend ( ) const
inlinenoexcept

Returns the read-only reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ data() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD const_pointer gaia::cnt::darr_ext< T, N, Allocator >::data ( ) const
inlinenoexcept

Returns a pointer to the element storage.

Returns
Pointer to the first element storage location.

◆ data() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD pointer gaia::cnt::darr_ext< T, N, Allocator >::data ( )
inlinenoexcept

Returns a pointer to the element storage.

Returns
Pointer to the first element storage location.

◆ emplace_back()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
template<typename... Args>
decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::emplace_back ( Args &&...  args)
inline

Constructs and appends an element.

Template Parameters
ArgsTypes of the forwarded constructor arguments.
Parameters
argsArguments forwarded to the element constructor.
Returns
Reference to the appended element.

◆ empty()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD bool gaia::cnt::darr_ext< T, N, Allocator >::empty ( ) const
inlinenoexcept

Checks whether the container has no elements.

Returns
True if the container contains no elements.

◆ end() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::end ( ) const
inlinenoexcept

Returns an iterator one past the last element.

Returns
Iterator one past the last element.

◆ end() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::end ( )
inlinenoexcept

Returns an iterator one past the last element.

Returns
Iterator one past the last element.

◆ erase() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
iterator gaia::cnt::darr_ext< T, N, Allocator >::erase ( iterator  first,
iterator  last 
)
inlinenoexcept

Removes the elements in the range [first, last)

Returns
Iterator to the element following the removed element or range.
Parameters
firstIterator to the element to remove
lastIterator to the one beyond the last element to remove

◆ erase() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
iterator gaia::cnt::darr_ext< T, N, Allocator >::erase ( iterator  pos)
inlinenoexcept

Removes the element at pos.

Returns
Iterator to the element following the removed element or range.
Parameters
posIterator to the element to remove

◆ front() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::front ( ) const
inlinenoexcept

Accesses the first element.

Returns
Reference to the first element.

◆ front() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::front ( )
inlinenoexcept

Accesses the first element.

Returns
Reference to the first element.

◆ insert() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
iterator gaia::cnt::darr_ext< T, N, Allocator >::insert ( iterator  pos,
const T arg 
)
inline

Insert the element to the position given by iterator pos.

Returns
Iterator to the inserted element.
Parameters
posPosition in the container
argData to insert

◆ insert() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
iterator gaia::cnt::darr_ext< T, N, Allocator >::insert ( iterator  pos,
T &&  arg 
)
inline

Insert the element to the position given by iterator pos.

Returns
Iterator to the inserted element.
Parameters
posPositing in the container
argData to insert

◆ max_size()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD size_type gaia::cnt::darr_ext< T, N, Allocator >::max_size ( ) const
inlinenoexcept

Returns the maximum number of elements supported by this container.

Returns
Maximum supported element count.

◆ operator!=()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD constexpr bool gaia::cnt::darr_ext< T, N, Allocator >::operator!= ( const darr_ext< T, N, Allocator > &  other) const
inlineconstexprnoexcept

Checks whether two containers differ.

Parameters
otherContainer to copy or move from.
Returns
True if the containers differ.

◆ operator=() [1/3]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
darr_ext & gaia::cnt::darr_ext< T, N, Allocator >::operator= ( const darr_ext< T, N, Allocator > &  other)
inline

Copy-assigns the container.

Parameters
otherContainer to copy or move from.
Returns
Reference to this container.

◆ operator=() [2/3]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
darr_ext & gaia::cnt::darr_ext< T, N, Allocator >::operator= ( darr_ext< T, N, Allocator > &&  other)
inlinenoexcept

Move-assigns the container.

Parameters
otherContainer to copy or move from.
Returns
Reference to this container.

◆ operator=() [3/3]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
darr_ext & gaia::cnt::darr_ext< T, N, Allocator >::operator= ( std::initializer_list< T il)
inline

Replaces the elements from an initializer list.

Parameters
ilInitializer list supplying the elements.
Returns
Reference to this container.

◆ operator==()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD bool gaia::cnt::darr_ext< T, N, Allocator >::operator== ( const darr_ext< T, N, Allocator > &  other) const
inlinenoexcept

Compares two containers element by element.

Parameters
otherContainer to copy or move from.
Returns
True if both containers contain equal elements.

◆ operator[]() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::operator[] ( size_type  pos) const
inlinenoexcept

Accesses an element without bounds checking in optimized builds.

Parameters
posZero-based element index.
Returns
Reference to the selected element.

◆ operator[]() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD decltype(auto) gaia::cnt::darr_ext< T, N, Allocator >::operator[] ( size_type  pos)
inlinenoexcept

Accesses an element without bounds checking in optimized builds.

Parameters
posZero-based element index.
Returns
Reference to the selected element.

◆ push_back() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
void gaia::cnt::darr_ext< T, N, Allocator >::push_back ( const T arg)
inline

Appends an element.

Parameters
argElement value to append.

◆ push_back() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
void gaia::cnt::darr_ext< T, N, Allocator >::push_back ( T &&  arg)
inline

Appends an element.

Parameters
argElement value to append.

◆ rbegin() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::rbegin ( ) const
inlinenoexcept

Returns a reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ rbegin() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::rbegin ( )
inlinenoexcept

Returns a reverse traversal iterator to the last element.

Returns
Iterator to the last element.

◆ rend() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::rend ( ) const
inlinenoexcept

Returns the reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ rend() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD auto gaia::cnt::darr_ext< T, N, Allocator >::rend ( )
inlinenoexcept

Returns the reverse traversal sentinel preceding the first element.

Returns
Reverse traversal sentinel preceding the first element.

◆ reserve()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
void gaia::cnt::darr_ext< T, N, Allocator >::reserve ( size_type  cap)
inline

Ensures storage for at least the requested number of elements.

Parameters
capRequested element capacity.

◆ resize() [1/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
void gaia::cnt::darr_ext< T, N, Allocator >::resize ( size_type  count)
inline

Changes the number of elements.

Parameters
countNumber of elements.

◆ resize() [2/2]

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
void gaia::cnt::darr_ext< T, N, Allocator >::resize ( size_type  count,
const_reference  value 
)
inline

Changes the size and initializes new elements from a value.

Parameters
countNumber of elements.
valueValue assigned to each new element.

◆ retain()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
template<typename Func >
auto gaia::cnt::darr_ext< T, N, Allocator >::retain ( Func &&  func)
inlinenoexcept

Removes all elements that fail the predicate.

Template Parameters
FuncPredicate callable type.
Parameters
funcA lambda or a functor with the bool operator()(Container::value_type&) overload.
Returns
The new size of the array.

◆ size()

template<typename T , darr_ext_detail::size_type N, typename Allocator = mem::DefaultAllocatorAdaptor>
GAIA_NODISCARD size_type gaia::cnt::darr_ext< T, N, Allocator >::size ( ) const
inlinenoexcept

Returns the number of elements.

Returns
Current element count.

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