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>

Detailed Description

template<typename StoredType, std::size_t MaxSize>
class AStaticVector< StoredType, MaxSize >
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

> All members, including inherited

◆ 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
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