AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AStaticVector< StoredType, MaxSize > Class Template Reference

Vector-like container up to maxSize elements inplace. More...

#include <AUI/Common/AStaticVector.h>

Public Types

using self = AStaticVector
 
using super = AStaticVector
 
using iterator = StoredType*
 
using const_iterator = const StoredType*
 
using reference = StoredType&
 
using const_reference = const StoredType&
 
using value = StoredType
 

Public Member Functions

constexpr AStaticVector (const AStaticVector &rhs)
 
constexpr AStaticVector (AStaticVector &&rhs) noexcept
 
constexpr AStaticVector (std::initializer_list< StoredType > rhs) noexcept
 
template<typename Iterator>
constexpr AStaticVector (Iterator begin, Iterator end) noexcept
 
AStaticVectoroperator= (const AStaticVector &rhs)
 
AStaticVectoroperator= (AStaticVector &&rhs) noexcept
 
constexpr bool full () const noexcept
 
constexpr StoredType * data () noexcept
 
constexpr const StoredType * data () const noexcept
 
constexpr iterator begin () noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr iterator end () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr StoredType & front () noexcept
 
constexpr StoredType & back () noexcept
 
constexpr const StoredType & front () const noexcept
 
constexpr const StoredType & back () const noexcept
 
template<typename... Args>
constexpr void emplace_back (Args &&... args) noexcept
 
constexpr void push_back (StoredType value) noexcept
 
constexpr void push_front (StoredType value) noexcept
 
constexpr void pop_back () noexcept
 
constexpr void pop_front () noexcept
 
constexpr StoredType & operator[] (std::size_t index) noexcept
 
constexpr StoredType & operator[] (std::size_t index) const noexcept
 
constexpr bool empty () const noexcept
 
constexpr void clear () noexcept
 
constexpr std::size_t size () const noexcept
 
template<typename OtherIterator>
constexpr iterator insert (iterator at, OtherIterator begin, OtherIterator end)
 
constexpr iterator insert (iterator at, StoredType value)
 
constexpr iterator erase (iterator at)
 
constexpr iterator erase (iterator begin, iterator end)
 
void reserve (std::size_t)
 
template<typename OtherContainer>
iterator insertAll (const OtherContainer &c) noexcept
 
template<typename OtherContainer>
iterator insertAll (OtherContainer &&c) noexcept
 
template<typename OtherContainer>
iterator insertAll (iterator at, const OtherContainer &c) noexcept
 
template<typename OtherContainer>
iterator insertAll (iterator at, OtherContainer &&c) noexcept
 
void removeAll (const StoredType &item) noexcept
 
void removeFirst (const StoredType &item) noexcept
 
template<typename OtherContainer>
bool isSubsetOf (const OtherContainer &c) const noexcept
 
bool contains (const StoredType &value) const noexcept
 
std::size_t sizeInBytes () const noexcept
 
StoredType & at (std::size_t index)
 
const StoredType & at (std::size_t index) const
 
selfoperator<< (const StoredType &rhs) noexcept
 
selfoperator<< (StoredType &&rhs) noexcept
 
template<typename OtherContainer, std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
selfoperator<< (const OtherContainer &c) noexcept
 
template<typename OtherContainer, std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
selfoperator<< (OtherContainer &&c) noexcept
 
StoredType & first () noexcept
 
const StoredType & first () const noexcept
 
StoredType & last () noexcept
 
const StoredType & last () const noexcept
 
AOptional< size_t > indexOf (const StoredType &value) const noexcept
 
void sort () noexcept
 
template<typename Comparator>
void sort (Comparator &&comparator) noexcept
 
void removeAt (size_t index) noexcept
 
template<typename Predicate>
void removeIf (Predicate &&predicate) noexcept
 
ASet< StoredType > toSet () const noexcept
 
template<aui::invocable< const StoredType & > UnaryOperation>
auto map (UnaryOperation &&transformer) const -> AVector< decltype(transformer(std::declval< StoredType >()))>
 
template<aui::invocable< const StoredType & > UnaryOperation>
auto toMap (UnaryOperation &&transformer) const -> AMap< decltype(transformer(std::declval< StoredType >()).first), decltype(transformer(std::declval< StoredType >()).second)>
 
template<aui::invocable< StoredType & > UnaryOperation>
auto toMap (UnaryOperation &&transformer) -> AMap< decltype(transformer(std::declval< StoredType >()).first), decltype(transformer(std::declval< StoredType >()).second)>
 
template<aui::predicate< const StoredType & > Predicate>
self filter (Predicate &&predicate)
 
 operator std::span< StoredType > ()
 
 operator std::span< const StoredType > () const
 

Static Public Member Functions

static constexpr size_t capacity () noexcept
 
template<aui::incrementable Iterator, aui::invocable< decltype(*std::declval< Iterator >())> UnaryOperation>
static auto fromRange (aui::range< Iterator > range, UnaryOperation &&transformer) -> AVector< decltype(transformer(range.first()))>
 Constructs a new vector of transformed items of the range.
 

Detailed Description

template<typename StoredType, std::size_t MaxSize>
class AStaticVector< StoredType, MaxSize >

Vector-like container up to maxSize elements inplace.

Template Parameters
Tstored type
maxSizemaximum vector size

Vector-like container optimized for the case when it contains up to maxSize in place, avoiding dynamic allocation. AStaticVector could not contain more than maxSize elements.

Member Function Documentation

◆ contains()

template<typename StoredType, std::size_t MaxSize>
bool AStaticVector< StoredType, MaxSize >::contains ( const StoredType & value) const
inlinenoexcept
Returns
true if container contains an element, false otherwise.

◆ first() [1/2]

template<typename StoredType, std::size_t MaxSize>
const StoredType & AStaticVector< StoredType, MaxSize >::first ( ) const
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the first element.

◆ first() [2/2]

template<typename StoredType, std::size_t MaxSize>
StoredType & AStaticVector< StoredType, MaxSize >::first ( )
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the first element.

◆ fromRange()

template<typename StoredType, std::size_t MaxSize>
template<aui::incrementable Iterator, aui::invocable< decltype(*std::declval< Iterator >())> UnaryOperation>
static auto AStaticVector< StoredType, MaxSize >::fromRange ( aui::range< Iterator > range,
UnaryOperation && transformer ) -> AVector<decltype(transformer(range.first()))>
inlinestatic

Constructs a new vector of transformed items of the range.

Parameters
rangeitems to transform from.
transformertransformer function.
Returns
A new vector.

◆ indexOf()

template<typename StoredType, std::size_t MaxSize>
AOptional< size_t > AStaticVector< StoredType, MaxSize >::indexOf ( const StoredType & value) const
inlinenodiscardnoexcept
Parameters
valueelement to find.
Returns
index of the specified element. If element is not found, std::nullopt is returned.

◆ insertAll() [1/4]

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer>
iterator AStaticVector< StoredType, MaxSize >::insertAll ( const OtherContainer & c)
inlinenoexcept

Inserts all values of the specified container to the end.

Template Parameters
OtherContainerother container type.
Parameters
cother container
Returns
iterator pointing to the first element inserted.

◆ insertAll() [2/4]

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer>
iterator AStaticVector< StoredType, MaxSize >::insertAll ( iterator at,
const OtherContainer & c )
inlinenoexcept

Inserts all values of the specified container.

Template Parameters
OtherContainerother container type.
Parameters
atposition to insert at.
cother container
Returns
iterator pointing to the first element inserted.

◆ insertAll() [3/4]

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer>
iterator AStaticVector< StoredType, MaxSize >::insertAll ( iterator at,
OtherContainer && c )
inlinenoexcept

Inserts all values of the specified container.

Template Parameters
OtherContainerother container type.
Parameters
atposition to insert at.
cother container
Returns
iterator pointing to the first element inserted.

◆ insertAll() [4/4]

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer>
iterator AStaticVector< StoredType, MaxSize >::insertAll ( OtherContainer && c)
inlinenoexcept

Inserts all values of the specified container to the end.

Template Parameters
OtherContainerother container type.
Parameters
cother container
Returns
iterator pointing to the first element inserted.

◆ isSubsetOf()

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer>
bool AStaticVector< StoredType, MaxSize >::isSubsetOf ( const OtherContainer & c) const
inlinenoexcept
Returns
true if c container is a subset of this container, false otherwise.

◆ last() [1/2]

template<typename StoredType, std::size_t MaxSize>
const StoredType & AStaticVector< StoredType, MaxSize >::last ( ) const
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the last element.

◆ last() [2/2]

template<typename StoredType, std::size_t MaxSize>
StoredType & AStaticVector< StoredType, MaxSize >::last ( )
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the last element.

◆ operator<<() [1/4]

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer, std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
self & AStaticVector< StoredType, MaxSize >::operator<< ( const OtherContainer & c)
inlinenoexcept

Shortcut to insertAll.

Parameters
ccontainer to push
Returns
self

◆ operator<<() [2/4]

template<typename StoredType, std::size_t MaxSize>
self & AStaticVector< StoredType, MaxSize >::operator<< ( const StoredType & rhs)
inlinenoexcept

Shortcut to push_back.

Parameters
rhsvalue to push
Returns
self

◆ operator<<() [3/4]

template<typename StoredType, std::size_t MaxSize>
template<typename OtherContainer, std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
self & AStaticVector< StoredType, MaxSize >::operator<< ( OtherContainer && c)
inlinenoexcept

Shortcut to insertAll.

Parameters
ccontainer to push
Returns
self

◆ operator<<() [4/4]

template<typename StoredType, std::size_t MaxSize>
self & AStaticVector< StoredType, MaxSize >::operator<< ( StoredType && rhs)
inlinenoexcept

Shortcut to push_back.

Parameters
rhsvalue to push
Returns
self

◆ removeAll()

template<typename StoredType, std::size_t MaxSize>
void AStaticVector< StoredType, MaxSize >::removeAll ( const StoredType & item)
inlinenoexcept

Removes all occurrences of item.

Parameters
itemelement to remove.

◆ removeAt()

template<typename StoredType, std::size_t MaxSize>
void AStaticVector< StoredType, MaxSize >::removeAt ( size_t index)
inlinenoexcept

Removes element at the specified index.

Sneaky assertions
index points to the existing element.
Parameters
indexindex of the element.

◆ removeFirst()

template<typename StoredType, std::size_t MaxSize>
void AStaticVector< StoredType, MaxSize >::removeFirst ( const StoredType & item)
inlinenoexcept

Removes first occurrence of item.

Parameters
itemelement to remove.

◆ removeIf()

template<typename StoredType, std::size_t MaxSize>
template<typename Predicate>
void AStaticVector< StoredType, MaxSize >::removeIf ( Predicate && predicate)
inlinenoexcept

Removes element if predicate(container[i]) == true.

Parameters
predicatepredicate

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