Vector-like container consisting of few elements on stack and switches to dynamic allocation vector if needed.
More...
#include <AUI/Common/ASmallVector.h>
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
class ASmallVector< StoredType, StaticVectorSize, Allocator >
- Template Parameters
-
StoredType | stored type |
StaticVectorSize | how many elements can be stored without dynamic allocation |
Allocator | allocation |
Vector-like container optimized for the case when it contains up to StaticVectorSize in place, avoiding dynamic allocation. In case when element count exceeds StaticVectorSize, ASmallVector seamlessly switches to traditional dynamic allocation vector.
> All members, including inherited
◆ contains()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
bool ASmallVector< StoredType, StaticVectorSize, Allocator >::contains |
( |
const StoredType & | value | ) |
const |
|
inlinenoexcept |
- Returns
- true if container contains an element, false otherwise.
◆ findIf() [1/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename T,
aui::mapper< const StoredType &, const T & > Projection>
StoredType * ASmallVector< StoredType, StaticVectorSize, Allocator >::findIf |
( |
const T & | value, |
|
|
Projection && | projection ) |
|
inlinenoexcept |
- Parameters
-
value | value |
projection | callable that transforms const StoredType& to const T& . Can be any operator() cappable object, including lambda and pointer-to-member. |
- Returns
- Pointer to the value on which the predicate returned true, nullptr otherwise
◆ findIf() [2/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
StoredType * ASmallVector< StoredType, StaticVectorSize, Allocator >::findIf |
( |
Predicate && | predicate | ) |
|
|
inlinenoexcept |
- Parameters
-
- Returns
- Pointer to the value on which the predicate returned true, nullptr otherwise
◆ first() [1/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
const StoredType & ASmallVector< StoredType, StaticVectorSize, Allocator >::first |
( |
| ) |
const |
|
inlinenoexcept |
- Sneaky assertions
- Container is not empty.
- Returns
- the first element.
◆ first() [2/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
StoredType & ASmallVector< StoredType, StaticVectorSize, Allocator >::first |
( |
| ) |
|
|
inlinenoexcept |
- Sneaky assertions
- Container is not empty.
- Returns
- the first element.
◆ fromRange()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
static auto ASmallVector< StoredType, StaticVectorSize, Allocator >::fromRange |
( |
aui::range< Iterator > | range, |
|
|
UnaryOperation && | transformer ) -> AVector<decltype(transformer(range.first()))> |
|
inlinestatic |
- Parameters
-
range | items to transform from. |
transformer | transformer function. |
- Returns
- A new vector.
◆ indexOf()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
AOptional< size_t > ASmallVector< StoredType, StaticVectorSize, Allocator >::indexOf |
( |
const StoredType & | value | ) |
const |
|
inlinenodiscardnoexcept |
- Parameters
-
- Returns
- index of the specified element. If element is not found, std::nullopt is returned.
◆ insertAll() [1/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer>
iterator ASmallVector< StoredType, StaticVectorSize, Allocator >::insertAll |
( |
const OtherContainer & | c | ) |
|
|
inlinenoexcept |
Inserts all values of the specified container to the end.
- Template Parameters
-
OtherContainer | other container type. |
- Parameters
-
- Returns
- iterator pointing to the first element inserted.
◆ insertAll() [2/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer>
iterator ASmallVector< StoredType, StaticVectorSize, Allocator >::insertAll |
( |
iterator | at, |
|
|
const OtherContainer & | c ) |
|
inlinenoexcept |
Inserts all values of the specified container.
- Template Parameters
-
OtherContainer | other container type. |
- Parameters
-
at | position to insert at. |
c | other container |
- Returns
- iterator pointing to the first element inserted.
◆ insertAll() [3/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer>
iterator ASmallVector< StoredType, StaticVectorSize, Allocator >::insertAll |
( |
iterator | at, |
|
|
OtherContainer && | c ) |
|
inlinenoexcept |
Inserts all values of the specified container.
- Template Parameters
-
OtherContainer | other container type. |
- Parameters
-
at | position to insert at. |
c | other container |
- Returns
- iterator pointing to the first element inserted.
◆ insertAll() [4/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer>
iterator ASmallVector< StoredType, StaticVectorSize, Allocator >::insertAll |
( |
OtherContainer && | c | ) |
|
|
inlinenoexcept |
Inserts all values of the specified container to the end.
- Template Parameters
-
OtherContainer | other container type. |
- Parameters
-
- Returns
- iterator pointing to the first element inserted.
◆ isSubsetOf()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer>
bool ASmallVector< StoredType, StaticVectorSize, Allocator >::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 StaticVectorSize, typename Allocator = std::allocator<StoredType>>
const StoredType & ASmallVector< StoredType, StaticVectorSize, Allocator >::last |
( |
| ) |
const |
|
inlinenoexcept |
- Sneaky assertions
- Container is not empty.
- Returns
- the last element.
◆ last() [2/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
StoredType & ASmallVector< StoredType, StaticVectorSize, Allocator >::last |
( |
| ) |
|
|
inlinenoexcept |
- Sneaky assertions
- Container is not empty.
- Returns
- the last element.
◆ operator<<() [1/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer, std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
self & ASmallVector< StoredType, StaticVectorSize, Allocator >::operator<< |
( |
const OtherContainer & | c | ) |
|
|
inlinenoexcept |
Shortcut to insertAll
.
- Parameters
-
- Returns
- self
◆ operator<<() [2/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
self & ASmallVector< StoredType, StaticVectorSize, Allocator >::operator<< |
( |
const StoredType & | rhs | ) |
|
|
inlinenoexcept |
Shortcut to push_back
.
- Parameters
-
- Returns
- self
◆ operator<<() [3/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename OtherContainer, std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
self & ASmallVector< StoredType, StaticVectorSize, Allocator >::operator<< |
( |
OtherContainer && | c | ) |
|
|
inlinenoexcept |
Shortcut to insertAll
.
- Parameters
-
- Returns
- self
◆ operator<<() [4/4]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
self & ASmallVector< StoredType, StaticVectorSize, Allocator >::operator<< |
( |
StoredType && | rhs | ) |
|
|
inlinenoexcept |
Shortcut to push_back
.
- Parameters
-
- Returns
- self
◆ removeAll() [1/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
void ASmallVector< StoredType, StaticVectorSize, Allocator >::removeAll |
( |
const StoredType & | item | ) |
|
|
inlinenoexcept |
Removes all occurrences of item
.
- Parameters
-
◆ removeAll() [2/2]
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename T,
aui::mapper< const StoredType &, const T & > Projection>
void ASmallVector< StoredType, StaticVectorSize, Allocator >::removeAll |
( |
const T & | item, |
|
|
Projection | projection ) |
|
inlinenoexcept |
Removes all occurrences of item
with specified projection.
- Parameters
-
item | element to remove. |
projection | callable that transforms const StoredType& to const T& . Can be any operator() cappable object, including lambda and pointer-to-member. |
◆ removeAt()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
void ASmallVector< StoredType, StaticVectorSize, Allocator >::removeAt |
( |
size_t | index | ) |
|
|
inlinenoexcept |
Removes element at the specified index.
- Sneaky assertions
index
points to the existing element.
- Parameters
-
index | index of the element. |
◆ removeFirst()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
void ASmallVector< StoredType, StaticVectorSize, Allocator >::removeFirst |
( |
const StoredType & | item | ) |
|
|
inlinenoexcept |
Removes first occurrence of item
.
- Parameters
-
◆ removeIf()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
template<typename Predicate>
void ASmallVector< StoredType, StaticVectorSize, Allocator >::removeIf |
( |
Predicate && | predicate | ) |
|
|
inlinenoexcept |
Removes element if predicate(container[i]) == true.
- Parameters
-
◆ size()
template<typename StoredType, std::size_t StaticVectorSize, typename Allocator = std::allocator<StoredType>>
std::size_t ASmallVector< StoredType, StaticVectorSize, Allocator >::size |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
- Returns
- Size of the container.