AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AVector< StoredType, Allocator > Class Template Reference

A std::vector with AUI extensions. More...

Detailed Description

template<class StoredType, class Allocator>
class AVector< StoredType, Allocator >

A std::vector with AUI extensions.

Examples
/github/workspace/aui.core/src/AUI/IO/APath.h, /github/workspace/aui.json/src/AUI/Json/Conversion.h, /github/workspace/aui.views/src/AUI/View/AView.h, and Typical.

Public Types

using iterator = typename super::iterator
 

Public Member Functions

template<typename Iterator >
 AVector (aui::range< Iterator > range)
 
 AVector (std::vector< StoredType, Allocator > &&rhs) noexcept
 
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
 
template<typename T , aui::mapper< const StoredType &, const T & > Projection>
void removeAll (const T &item, Projection projection) noexcept
 
AOptional< std::size_t > 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
 
size_t indexOf (const StoredType &value) const noexcept
 
AVector< StoredType > & sort () noexcept
 
template<typename Comparator >
AVector< StoredType > & sort (Comparator &&comparator) noexcept
 
template<aui::predicate< StoredType > Predicate>
StoredType * findIf (Predicate &&predicate) noexcept
 Finds element by predicate. More...
 
void removeAt (size_t index) noexcept
 
template<aui::predicate< StoredType > Predicate>
void removeIf (Predicate &&predicate) noexcept
 
template<aui::predicate< StoredType > Predicate>
void removeIfFirst (Predicate &&predicate) noexcept
 
ASet< StoredType > toSet () const noexcept
 
template<aui::invocable< StoredType & > UnaryOperation>
auto map (UnaryOperation &&transformer) -> AVector< decltype(transformer(std::declval< StoredType & >()))>
 
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)
 

Static Public Member Functions

template<aui::mapper< std::size_t, StoredType > Callable>
static AVector< StoredType, Allocator > generate (size_t size, Callable &&callable) 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. More...
 

Protected Types

using super = std::vector< StoredType, Allocator >
 
using self = AVector< StoredType, Allocator >
 

Member Function Documentation

◆ contains()

template<class StoredType , class Allocator >
bool AVector< StoredType, Allocator >::contains ( const StoredType &  value) const
inlinenoexcept
Returns
true if container contains an element, false otherwise.

◆ findIf()

template<class StoredType , class Allocator >
template<aui::predicate< StoredType > Predicate>
StoredType * AVector< StoredType, Allocator >::findIf ( Predicate &&  predicate)
inlinenoexcept

Finds element by predicate.

Parameters
predicatepredicate
Returns
Pointer to the value on which the predicate returned true, nullptr otherwise

◆ first() [1/2]

template<class StoredType , class Allocator >
const StoredType & AVector< StoredType, Allocator >::first ( ) const
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the first element.

◆ first() [2/2]

template<class StoredType , class Allocator >
StoredType & AVector< StoredType, Allocator >::first ( )
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the first element.

◆ fromRange()

template<class StoredType , class Allocator >
template<aui::incrementable Iterator, aui::invocable< decltype(*std::declval< Iterator >())> UnaryOperation>
static auto AVector< StoredType, Allocator >::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<class StoredType , class Allocator >
size_t AVector< StoredType, Allocator >::indexOf ( const StoredType &  value) const
inlinenoexcept
Parameters
valueelement to find.
Returns
index of the specified element. If element is not found, -1 is returned.

◆ insertAll() [1/4]

template<class StoredType , class Allocator >
template<typename OtherContainer >
iterator AVector< StoredType, Allocator >::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<class StoredType , class Allocator >
template<typename OtherContainer >
iterator AVector< StoredType, Allocator >::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<class StoredType , class Allocator >
template<typename OtherContainer >
iterator AVector< StoredType, Allocator >::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<class StoredType , class Allocator >
template<typename OtherContainer >
iterator AVector< StoredType, Allocator >::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<class StoredType , class Allocator >
template<typename OtherContainer >
bool AVector< StoredType, Allocator >::isSubsetOf ( const OtherContainer &  c) const
inlinenoexcept
Returns
true if c container is a subset of this container, false otherwise.

◆ last() [1/2]

template<class StoredType , class Allocator >
const StoredType & AVector< StoredType, Allocator >::last ( ) const
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the last element.

◆ last() [2/2]

template<class StoredType , class Allocator >
StoredType & AVector< StoredType, Allocator >::last ( )
inlinenoexcept
Sneaky assertions
Container is not empty.
Returns
the last element.

◆ operator<<() [1/4]

template<class StoredType , class Allocator >
template<typename OtherContainer , std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
self & AVector< StoredType, Allocator >::operator<< ( const OtherContainer &  c)
inlinenoexcept

Shortcut to insertAll.

Parameters
rhscontainer to push
Returns
self

◆ operator<<() [2/4]

template<class StoredType , class Allocator >
self & AVector< StoredType, Allocator >::operator<< ( const StoredType &  rhs)
inlinenoexcept

Shortcut to push_back.

Parameters
rhsvalue to push
Returns
self

◆ operator<<() [3/4]

template<class StoredType , class Allocator >
template<typename OtherContainer , std::enable_if_t<!std::is_convertible_v< OtherContainer, StoredType >, bool > = true>
self & AVector< StoredType, Allocator >::operator<< ( OtherContainer &&  c)
inlinenoexcept

Shortcut to insertAll.

Parameters
rhscontainer to push
Returns
self

◆ operator<<() [4/4]

template<class StoredType , class Allocator >
self & AVector< StoredType, Allocator >::operator<< ( StoredType &&  rhs)
inlinenoexcept

Shortcut to push_back.

Parameters
rhsvalue to push
Returns
self

◆ removeAll() [1/2]

template<class StoredType , class Allocator >
void AVector< StoredType, Allocator >::removeAll ( const StoredType &  item)
inlinenoexcept

Removes all occurrences of item.

Parameters
itemelement to remove.

◆ removeAll() [2/2]

template<class StoredType , class Allocator >
template<typename T , aui::mapper< const StoredType &, const T & > Projection>
void AVector< StoredType, Allocator >::removeAll ( const T &  item,
Projection  projection 
)
inlinenoexcept

Removes all occurrences of item with specified projection.

Parameters
itemelement to remove.
projectioncallable that transforms const StoredType& to const T&. Can be any operator() cappable object, including lambda and pointer-to-member.

◆ removeAt()

template<class StoredType , class Allocator >
void AVector< StoredType, Allocator >::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<class StoredType , class Allocator >
AOptional< std::size_t > AVector< StoredType, Allocator >::removeFirst ( const StoredType &  item)
inlinenoexcept

Removes first occurrence of item.

Parameters
itemelement to remove.
Returns
If the item is removed, it's index returned.

◆ removeIf()

template<class StoredType , class Allocator >
template<aui::predicate< StoredType > Predicate>
void AVector< StoredType, Allocator >::removeIf ( Predicate &&  predicate)
inlinenoexcept

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

Parameters
predicatepredicate

◆ removeIfFirst()

template<class StoredType , class Allocator >
template<aui::predicate< StoredType > Predicate>
void AVector< StoredType, Allocator >::removeIfFirst ( Predicate &&  predicate)
inlinenoexcept

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

Parameters
predicatepredicate

#include <AUI/Common/AVector.h>


The documentation for this class was generated from the following files:
Inheritance diagram for AVector< StoredType, Allocator >:
Collaboration diagram for AVector< StoredType, Allocator >: