ActiveLib
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
active::container::Vector< T > Class Template Reference

#include <Vector.h>

Inheritance diagram for active::container::Vector< T >:
Inheritance graph
[legend]
Collaboration diagram for active::container::Vector< T >:
Collaboration graph
[legend]

Public Types

using base = std::vector<std::unique_ptr<T>>
 Base container type.
 
using value_type = typename base::value_type
 Stored type.
 
using size_type = typename base::size_type
 Container size (index) type.
 
using iterator = typename base::iterator
 Container iterator type.
 
using const_iterator = typename base::const_iterator
 Container const iterator type.
 

Public Member Functions

 Vector (size_type toReserve=0)
 
template<class Derived >
 Vector (const std::initializer_list< Derived > &items)
 
 Vector (const Vector &source)
 
 Vector (Vector &&source)
 
virtual ~Vector ()=default
 
auto operator= (const Vector &source)
 
auto operator= (Vector &&source)
 
void push_back (T *item)
 
void emplace_back (T &&item)
 
void emplace_back (const T &item)
 
void emplace_back (value_type &&item)
 
void emplace_back (value_type &item)
 
auto insert (const_iterator pos, T *item)
 
auto emplace (const_iterator pos, T &&item)
 
auto emplace (const_iterator pos, value_type &item)
 
auto release (iterator &pos)
 
auto release (const_iterator pos)
 

Detailed Description

template<class T>
requires utility::Clonable<T>
class active::container::Vector< T >

A specialisation class for a vector of objects wrapped in unique_ptr

This allows vector to store objects with polymorphic behaviour and object copying (object type must conform to Clonable). Keep in mind that the normal behaviour of the vector is to take ownership of any objects stored in it (unless release is used)

NB: There is no requirement for container items to be non-null. It is entirely up the implementor if this rule should be adopted or enforced

Constructor & Destructor Documentation

◆ Vector() [1/4]

template<class T >
active::container::Vector< T >::Vector ( size_type toReserve = 0)
inline

Constructor

Parameters
toReserveThe number of items to reserve space for in the vector

◆ Vector() [2/4]

template<class T >
template<class Derived >
active::container::Vector< T >::Vector ( const std::initializer_list< Derived > & items)
inlineexplicit

Constructor

Parameters
itemsThe items to insert in the array
Here is the call graph for this function:

◆ Vector() [3/4]

template<class T >
active::container::Vector< T >::Vector ( const Vector< T > & source)
inline

Copy constructor

Parameters
sourceThe object to copy

◆ Vector() [4/4]

template<class T >
active::container::Vector< T >::Vector ( Vector< T > && source)
inline

Move constructor

Parameters
sourceThe object to move

◆ ~Vector()

template<class T >
virtual active::container::Vector< T >::~Vector ( )
virtualdefault

Destructor

Member Function Documentation

◆ emplace() [1/2]

template<class T >
auto active::container::Vector< T >::emplace ( const_iterator pos,
T && item )
inline

Emplace an item into the vector at a specified position

Parameters
posThe insertion position
itemThe item to push (ownership passes to this vector)
Returns
An iterator pointing to the emplaced item

◆ emplace() [2/2]

template<class T >
auto active::container::Vector< T >::emplace ( const_iterator pos,
value_type & item )
inline

Emplace an item into the vector at a specified position

Parameters
posThe insertion position
itemThe item to push (ownership passes to this vector)
Returns
An iterator pointing to the emplaced item

◆ emplace_back() [1/4]

template<class T >
void active::container::Vector< T >::emplace_back ( const T & item)
inline

Push an item at the end of the vector

Parameters
itemThe item to push

◆ emplace_back() [2/4]

template<class T >
void active::container::Vector< T >::emplace_back ( T && item)
inline

Push an item at the end of the vector

Parameters
itemThe item to push
Here is the caller graph for this function:

◆ emplace_back() [3/4]

template<class T >
void active::container::Vector< T >::emplace_back ( value_type && item)
inline

Push an item at the end of the vector

Parameters
itemThe item to push (already wrapped in unique_ptr)

◆ emplace_back() [4/4]

template<class T >
void active::container::Vector< T >::emplace_back ( value_type & item)
inline

Push an item at the end of the vector

Parameters
itemThe item to push (already wrapped in unique_ptr)

◆ insert()

template<class T >
auto active::container::Vector< T >::insert ( const_iterator pos,
T * item )
inline

Insert an item into the vector at a specified position

Parameters
posThe insertion position
itemThe item to push (ownership passes to this vector)

◆ operator=() [1/2]

template<class T >
auto active::container::Vector< T >::operator= ( const Vector< T > & source)
inline

Assignment operator

Parameters
sourceThe object to copy
Returns
A reference to this

◆ operator=() [2/2]

template<class T >
auto active::container::Vector< T >::operator= ( Vector< T > && source)
inline

Assignment operator

Parameters
sourceThe object to move
Returns
A reference to this

◆ push_back()

template<class T >
void active::container::Vector< T >::push_back ( T * item)
inline

Push an item at the end of the vector

Parameters
itemThe item to push (ownership passes to this vector)
Here is the caller graph for this function:

◆ release() [1/2]

template<class T >
auto active::container::Vector< T >::release ( const_iterator pos)
inline

Release the pointer held by the specified item and erase

Parameters
posAn iterator pointing to the item to be removed
Returns
The released pointer from the list item

◆ release() [2/2]

template<class T >
auto active::container::Vector< T >::release ( iterator & pos)
inline

Release the pointer held by the specified item and erase

Parameters
posAn iterator pointing to the item to be removed
Returns
An iterator at the next value
Here is the call graph for this function:
Here is the caller graph for this function:

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