Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Types | Public Member Functions
ext::vector< T, Alloc > Class Template Reference

Class extending the vector class from the standard library. Original reason is to allow printing of the container with overloaded operator <<. More...

#include <vector.hpp>

Inheritance diagram for ext::vector< T, Alloc >:
[legend]
Collaboration diagram for ext::vector< T, Alloc >:
[legend]

Public Types

using iterator = typename std::vector< T, Alloc >::iterator
 The type of values iterator. More...
 
using const_iterator = typename std::vector< T, Alloc >::const_iterator
 The type of constant values iterator. More...
 
using reverse_iterator = typename std::vector< T, Alloc >::reverse_iterator
 The type of reverse values iterator. More...
 
using const_reverse_iterator = typename std::vector< T, Alloc >::const_reverse_iterator
 The type of constant reverse values iterator. More...
 

Public Member Functions

 vector ()=default
 
 vector (const vector &other)=default
 
 vector (vector &&other)=default
 
vectoroperator= (vector &&other)=default
 
vectoroperator= (const vector &other)=default
 
template<class Iterator >
 vector (const ext::iterator_range< Iterator > &range)
 
auto begin () &
 Inherited behavior of begin for non-const instance. More...
 
auto begin () const &
 Inherited behavior of begin for const instance. More...
 
auto begin () &&
 Inherited behavior of begin for rvalues. More...
 
auto end () &
 Inherited behavior of end for non-const instance. More...
 
auto end () const &
 Inherited behavior of end for const instance. More...
 
auto end () &&
 Inherited behavior of end for rvalues. More...
 
auto range () &
 Make range of non-const begin to end iterators. More...
 
auto range () const &
 Make range of non-const begin to end iterators. More...
 
auto range () &&
 Make range of move begin to end iterators. More...
 
reverse_iterator insert (const_reverse_iterator pos, const T &value)
 Inserts the value on position given by iterator pos. More...
 
reverse_iterator insert (const_reverse_iterator pos, T &&value)
 Inserts the value on position given by iterator pos. More...
 
reverse_iterator insert (const_reverse_iterator pos, size_t count, const T &value)
 Inserts the count copies of value on position given by iterator pos. More...
 
template<class InputIt >
reverse_iterator insert (const_reverse_iterator pos, InputIt first, InputIt last)
 Inserts the values from the given range to positions starting at given iterator pos. More...
 
reverse_iterator insert (const_reverse_iterator pos, std::initializer_list< T > ilist)
 Inserts the values from the given initializer list to positions starting at given iterator pos. More...
 
template<class ... Args>
reverse_iterator emplace (const_reverse_iterator pos, Args &&... args)
 Inserts a new value to the container at position given by parameter pos. The new value is constructed inside the method from constructor parameters. More...
 
iterator erase (iterator pos)
 Removes element from the container at position given by parameter pos. More...
 
reverse_iterator erase (reverse_iterator pos)
 Removes element from the container at position given by parameter pos. More...
 
reverse_iterator erase (const_reverse_iterator pos)
 Removes element from the container at position given by parameter pos. More...
 
iterator erase (iterator first, iterator last)
 Removes elements from the container in range given parameters first and last. More...
 
reverse_iterator erase (reverse_iterator first, reverse_iterator last)
 Removes elements from the container in range given parameters first and last. More...
 
reverse_iterator erase (const_reverse_iterator first, const_reverse_iterator last)
 Removes elements from the container in range given parameters first and last. More...
 

Detailed Description

template<class T, class Alloc = std::allocator < T >>
class ext::vector< T, Alloc >

Class extending the vector class from the standard library. Original reason is to allow printing of the container with overloaded operator <<.

The class mimics the behavior of the vector from the standatd library.

Template Parameters
Tthe type of values inside the vector
Allocthe allocator of values of type T

Member Typedef Documentation

◆ const_iterator

template<class T , class Alloc = std::allocator < T >>
using ext::vector< T, Alloc >::const_iterator = typename std::vector < T, Alloc >::const_iterator

The type of constant values iterator.

◆ const_reverse_iterator

template<class T , class Alloc = std::allocator < T >>
using ext::vector< T, Alloc >::const_reverse_iterator = typename std::vector < T, Alloc >::const_reverse_iterator

The type of constant reverse values iterator.

◆ iterator

template<class T , class Alloc = std::allocator < T >>
using ext::vector< T, Alloc >::iterator = typename std::vector < T, Alloc >::iterator

The type of values iterator.

◆ reverse_iterator

template<class T , class Alloc = std::allocator < T >>
using ext::vector< T, Alloc >::reverse_iterator = typename std::vector < T, Alloc >::reverse_iterator

The type of reverse values iterator.

Constructor & Destructor Documentation

◆ vector() [1/4]

template<class T , class Alloc = std::allocator < T >>
ext::vector< T, Alloc >::vector ( )
default

Default constructor needed by g++ since it is not inherited

◆ vector() [2/4]

template<class T , class Alloc = std::allocator < T >>
ext::vector< T, Alloc >::vector ( const vector< T, Alloc > &  other)
default

Copy constructor needed by g++ since it is not inherited

◆ vector() [3/4]

template<class T , class Alloc = std::allocator < T >>
ext::vector< T, Alloc >::vector ( vector< T, Alloc > &&  other)
default

Move constructor needed by g++ since it is not inherited

◆ vector() [4/4]

template<class T , class Alloc = std::allocator < T >>
template<class Iterator >
ext::vector< T, Alloc >::vector ( const ext::iterator_range< Iterator > &  range)
inlineexplicit

Constructor from range of values.

Template Parameters
Iteratorthe type of range iterator
Parameters
rangethe source range

Member Function Documentation

◆ begin() [1/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::begin ( ) &
inline

Inherited behavior of begin for non-const instance.

Returns
iterator the first element of vector
Here is the call graph for this function:

◆ begin() [2/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::begin ( ) &&
inline

Inherited behavior of begin for rvalues.

Returns
move_iterator the first element of vector
Here is the call graph for this function:

◆ begin() [3/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::begin ( ) const &
inline

Inherited behavior of begin for const instance.

Returns
const_iterator the first element of vector
Here is the call graph for this function:

◆ emplace()

template<class T , class Alloc = std::allocator < T >>
template<class ... Args>
reverse_iterator ext::vector< T, Alloc >::emplace ( const_reverse_iterator  pos,
Args &&...  args 
)
inline

Inserts a new value to the container at position given by parameter pos. The new value is constructed inside the method from constructor parameters.

Template Parameters
Args... the types of arguments of the T constructor
Parameters
posthe position to set
args... the arguments of the T constructor
Returns
updated iterator to the newly inserted value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [1/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::end ( ) &
inline

Inherited behavior of end for non-const instance.

Returns
iterator to one after the last element of vector
Here is the call graph for this function:

◆ end() [2/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::end ( ) &&
inline

Inherited behavior of end for rvalues.

Returns
move_iterator to one after the last element of vector
Here is the call graph for this function:

◆ end() [3/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::end ( ) const &
inline

Inherited behavior of end for const instance.

Returns
const_iterator to one after the last element of vector
Here is the call graph for this function:

◆ erase() [1/6]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::erase ( const_reverse_iterator  first,
const_reverse_iterator  last 
)
inline

Removes elements from the container in range given parameters first and last.

Parameters
firstthe begining of the removed range
lastthe end of the removed range
Returns
updated iterator to value after the removed ones
Here is the call graph for this function:

◆ erase() [2/6]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::erase ( const_reverse_iterator  pos)
inline

Removes element from the container at position given by parameter pos.

Parameters
posthe iterator pointing to the value to removed
Returns
updated iterator to value after the removed one
Here is the call graph for this function:

◆ erase() [3/6]

template<class T , class Alloc = std::allocator < T >>
iterator ext::vector< T, Alloc >::erase ( iterator  first,
iterator  last 
)
inline

Removes elements from the container in range given parameters first and last.

Parameters
firstthe begining of the removed range
lastthe end of the removed range
Returns
updated iterator to value after the removed ones
Here is the call graph for this function:

◆ erase() [4/6]

template<class T , class Alloc = std::allocator < T >>
iterator ext::vector< T, Alloc >::erase ( iterator  pos)
inline

Removes element from the container at position given by parameter pos.

Parameters
posthe iterator pointing to the value to removed
Returns
updated iterator to value after the removed one
Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase() [5/6]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::erase ( reverse_iterator  first,
reverse_iterator  last 
)
inline

Removes elements from the container in range given parameters first and last.

Parameters
firstthe begining of the removed range
lastthe end of the removed range
Returns
updated iterator to value after the removed ones
Here is the call graph for this function:

◆ erase() [6/6]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::erase ( reverse_iterator  pos)
inline

Removes element from the container at position given by parameter pos.

Parameters
posthe iterator pointing to the value to removed
Returns
updated iterator to value after the removed one
Here is the call graph for this function:

◆ insert() [1/5]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::insert ( const_reverse_iterator  pos,
const T &  value 
)
inline

Inserts the value on position given by iterator pos.

Parameters
posthe position to insert at
valuethe value to insert
Returns
updated iterator to the newly inserted value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [2/5]

template<class T , class Alloc = std::allocator < T >>
template<class InputIt >
reverse_iterator ext::vector< T, Alloc >::insert ( const_reverse_iterator  pos,
InputIt  first,
InputIt  last 
)
inline

Inserts the values from the given range to positions starting at given iterator pos.

Template Parameters
InputItthe iterator type
Parameters
firstthe begining of the range
lastthe end of the range
Returns
updated iterator to the newly inserted value
Here is the call graph for this function:

◆ insert() [3/5]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::insert ( const_reverse_iterator  pos,
size_t  count,
const T &  value 
)
inline

Inserts the count copies of value on position given by iterator pos.

Parameters
posthe position to insert at
countthe number of copies to insert
valuethe value to insert
Returns
updated iterator to the newly inserted value
Here is the call graph for this function:

◆ insert() [4/5]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::insert ( const_reverse_iterator  pos,
std::initializer_list< T >  ilist 
)
inline

Inserts the values from the given initializer list to positions starting at given iterator pos.

Parameters
posthe position to insert at
ilistthe initializer list
Returns
updated iterator to the newly inserted value
Here is the call graph for this function:

◆ insert() [5/5]

template<class T , class Alloc = std::allocator < T >>
reverse_iterator ext::vector< T, Alloc >::insert ( const_reverse_iterator  pos,
T &&  value 
)
inline

Inserts the value on position given by iterator pos.

Parameters
posthe position to insert at
valuethe value to insert
Returns
updated iterator to the newly inserted value
Here is the call graph for this function:

◆ operator=() [1/2]

template<class T , class Alloc = std::allocator < T >>
vector & ext::vector< T, Alloc >::operator= ( const vector< T, Alloc > &  other)
default

Move operator = needed by g++ since it is not inherited

◆ operator=() [2/2]

template<class T , class Alloc = std::allocator < T >>
vector & ext::vector< T, Alloc >::operator= ( vector< T, Alloc > &&  other)
default

Copy operator = needed by g++ since it is not inherited

◆ range() [1/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::range ( ) &
inline

Make range of non-const begin to end iterators.

Returns
full range over container values
Here is the call graph for this function:

◆ range() [2/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::range ( ) &&
inline

Make range of move begin to end iterators.

Returns
full range over container values

◆ range() [3/3]

template<class T , class Alloc = std::allocator < T >>
auto ext::vector< T, Alloc >::range ( ) const &
inline

Make range of non-const begin to end iterators.

Returns
full range over container values
Here is the call graph for this function:

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