Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
Implementation of vector storing dynamicaly allocated instances of given type. The class mimicks the iterface of the standard library vector, but effectively allows polymorphic objects to be stored inside. More...
#include <ptr_vector.hpp>
Public Types | |
using | value_type = T |
The type of values. More... | |
using | size_type = std::size_t |
The type of sizes. More... | |
using | diference_type = std::ptrdiff_t |
The type of size differences. More... | |
using | reference = value_type & |
The type of reference to values. More... | |
using | const_reference = const value_type & |
The type of reference to constant values. More... | |
using | pointer = T * |
The type of pointer to values. More... | |
using | const_pointer = const T * |
The type of pointer to constant value. More... | |
using | iterator = dereferencing_iterator< typename std::vector< T * >::iterator > |
The type of values iterator. More... | |
using | const_iterator = dereferencing_iterator< typename std::vector< T * >::const_iterator > |
The type of constant values iterator. More... | |
using | reverse_iterator = dereferencing_iterator< typename std::vector< T * >::reverse_iterator > |
The type of reverse values iterator. More... | |
using | const_reverse_iterator = dereferencing_iterator< typename std::vector< T * >::const_reverse_iterator > |
The type of constant reverse values iterator. More... | |
Public Member Functions | |
ptr_vector () noexcept=default | |
The default constructor creating empty vector. More... | |
template<class R > | |
ptr_vector (std::initializer_list< R > init) | |
The constructor of the vecto from initializer list. The vector will store dynamically allocated copies of objects from inside of the initializer list. More... | |
template<class R = T> | |
ptr_vector (size_type count) | |
The constructor of the vector of specific size. Elements of the vector are defaultly constructed values of type R. More... | |
template<class InputIt > | |
ptr_vector (InputIt first, InputIt last) | |
Constructor of the vector from range specified by iterators. More... | |
template<class Iterator > | |
ptr_vector (const ext::iterator_range< Iterator > &range) | |
template<class R > | |
ptr_vector (size_type count, const R &value) | |
Constructor of the vector of size given by count and filled with values from value . More... | |
ptr_vector (const ptr_vector &other) | |
Copy constrctor of the pointer vector. More... | |
ptr_vector (ptr_vector &&other) noexcept | |
Move constrctor of the pointer vector. More... | |
~ptr_vector () noexcept | |
The destructor of the vector. More... | |
ptr_vector< T > & | operator= (const ptr_vector< T > &other) |
The copy operator of assignment. More... | |
ptr_vector< T > & | operator= (ptr_vector< T > &&other) noexcept |
The move operator of assignment. More... | |
template<class R > | |
void | assign (size_type count, const R &value) |
Sets the content of the vector to value copied count times. More... | |
template<class InputIt > | |
void | assign (InputIt first, InputIt last) |
Sets the content of the vector to values in the given range. More... | |
template<class R > | |
void | assign (std::initializer_list< R > ilist) |
Sets the content of the vector to values in the initializer list. More... | |
reference | at (size_type index) |
Getter of a reference to the value on given index. More... | |
const_reference | at (size_type index) const |
Getter of a reference to the value on given index. More... | |
reference | operator[] (size_type index) |
Array subscript operator. More... | |
const_reference | operator[] (size_type index) const |
Array subscript operator. More... | |
reference | front () |
Getter of a value on the lowest index. More... | |
const_reference | front () const |
Getter of a value on the lowest index. More... | |
reference | back () |
Getter of a value on the highest index. More... | |
const_reference | back () const |
Getter of a value on the highest index. More... | |
iterator | begin () &noexcept |
Iterator to the begining of the values range in the vector. More... | |
const_iterator | begin () const &noexcept |
Const iterator to the begining of the values range in the vector. More... | |
auto | begin () &&noexcept |
Move iterator to the begining of the values range in the vector. More... | |
const_iterator | cbegin () const noexcept |
Iterator to the begining of the values range in the vector. More... | |
iterator | end () &noexcept |
Iterator one past the last element of the values range in the vector. More... | |
const_iterator | end () const &noexcept |
Const iterator one past the last element of the values range in the vector. More... | |
auto | end () &&noexcept |
Move iterator to the begining of the values range in the vector. More... | |
const_iterator | cend () const noexcept |
Iterator one past the last element of the values range in the vector. More... | |
reverse_iterator | rbegin () noexcept |
Reverse iterator to the begining of the reversed range of values in the vector. More... | |
const_reverse_iterator | rbegin () const noexcept |
Reverse iterator to the begining of the reversed range of values in the vector. More... | |
const_reverse_iterator | crbegin () const noexcept |
Reverse iterator to the begining of the reversed range of values in the vector. More... | |
reverse_iterator | rend () noexcept |
Reverse iterator one past the last element of the reversed range of values in the vector. More... | |
const_reverse_iterator | rend () const noexcept |
Reverse iterator one past the last element of the reversed range of values in the vector. More... | |
const_reverse_iterator | crend () const noexcept |
Reverse iterator one past the last element of the reversed range of values in the vector. 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... | |
bool | empty () const noexcept |
Array emptines test. More... | |
size_type | size () const noexcept |
Getter of the vector size. More... | |
size_type | max_size () const noexcept |
Returns the maximal number of values possible to store inside the container. More... | |
void | reserve (size_type new_cap) |
Prealocates space for given number of elements. Does not shrink the vector. More... | |
size_type | capacity () const noexcept |
Returns the preallocated size of the vector. More... | |
void | shrink_to_fit () |
Reallocates the vector to have the miniaml space overhead. More... | |
void | clear () noexcept |
Removes all values from the vector. More... | |
template<class R > | |
iterator | set (iterator pos, R &&value) |
Changes the value on position given by iterator pos . More... | |
template<class R > | |
iterator | set (const_iterator pos, R &&value) |
Changes the value on position given by iterator pos . More... | |
template<class R > | |
reverse_iterator | set (reverse_iterator pos, R &&value) |
Changes the value on position given by iterator pos . More... | |
template<class R > | |
reverse_iterator | set (const_reverse_iterator pos, R &&value) |
Changes the value on position given by iterator pos . More... | |
template<class R = T, class ... Args> | |
iterator | emplace_set (iterator pos, Args &&... args) |
Changes the value on position given by iterator pos . More... | |
template<class R = T, class ... Args> | |
iterator | emplace_set (const_iterator pos, Args &&... args) |
Changes the value on position given by iterator pos . More... | |
template<class R = T, class ... Args> | |
reverse_iterator | emplace_set (reverse_iterator pos, Args &&... args) |
Changes the value on position given by iterator pos . More... | |
template<class R = T, class ... Args> | |
reverse_iterator | emplace_set (const_reverse_iterator pos, Args &&... args) |
Changes the value on position given by iterator pos . More... | |
template<class R > | |
iterator | insert (iterator pos, R &&value) |
Inserts the value on position given by iterator pos . More... | |
template<class R > | |
iterator | insert (const_iterator pos, R &&value) |
Inserts the value on position given by iterator pos . More... | |
template<class R > | |
reverse_iterator | insert (reverse_iterator pos, R &&value) |
Inserts the value on position given by iterator pos . More... | |
template<class R > | |
reverse_iterator | insert (const_reverse_iterator pos, R &&value) |
Inserts the value on position given by iterator pos . More... | |
template<class R > | |
iterator | insert (iterator pos, size_type count, const R &value) |
Inserts the count copies of value on position given by iterator pos . More... | |
template<class R > | |
iterator | insert (const_iterator pos, size_type count, const R &value) |
Inserts the count copies of value on position given by iterator pos . More... | |
template<class R > | |
reverse_iterator | insert (reverse_iterator pos, size_type count, const R &value) |
Inserts the count copies of value on position given by iterator pos . More... | |
template<class R > | |
reverse_iterator | insert (const_reverse_iterator pos, size_type count, const R &value) |
Inserts the count copies of value on position given by iterator pos . More... | |
template<class InputIt > | |
iterator | insert (iterator pos, InputIt first, InputIt last) |
Inserts the values from the given range to positions starting at given iterator pos . More... | |
template<class InputIt > | |
iterator | insert (const_iterator pos, InputIt first, InputIt last) |
Inserts the values from the given range to positions starting at given iterator pos . More... | |
template<class InputIt > | |
reverse_iterator | insert (reverse_iterator pos, InputIt first, InputIt last) |
Inserts the values from the given range to positions starting at given 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... | |
template<class R > | |
iterator | insert (iterator pos, std::initializer_list< R > ilist) |
Inserts the values from the given initializer list to positions starting at given iterator pos . More... | |
template<class R > | |
iterator | insert (const_iterator pos, std::initializer_list< R > ilist) |
Inserts the values from the given initializer list to positions starting at given iterator pos . More... | |
template<class R > | |
reverse_iterator | insert (reverse_iterator pos, std::initializer_list< R > ilist) |
Inserts the values from the given initializer list to positions starting at given iterator pos . More... | |
template<class R > | |
reverse_iterator | insert (const_reverse_iterator pos, std::initializer_list< R > ilist) |
Inserts the values from the given initializer list to positions starting at given iterator pos . More... | |
template<class R = T, class ... Args> | |
iterator | emplace (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... | |
template<class R = T, class ... Args> | |
iterator | emplace (const_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... | |
template<class R = T, class ... Args> | |
reverse_iterator | emplace (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... | |
template<class R = T, 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... | |
iterator | erase (const_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... | |
iterator | erase (const_iterator first, const_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... | |
template<class R > | |
void | push_back (R &&value) |
Appends a new value at the end of the container. More... | |
template<class R = T, class ... Args> | |
reference | emplace_back (Args &&... args) |
Appends a new value at the end of the container. The value is constructed inside the method using provided constructor parameters. More... | |
void | pop_back () |
Removes element from the end of the container. More... | |
template<class R = T> | |
void | resize (size_type count) |
Changes the size of the vector, allocates new elements if the size increases. The possibly needed values are defaultly constructed values of type R. The vector can both increase or decrease in size. More... | |
template<class R > | |
void | resize (size_type count, const R &value) |
Changes the size of the vector. If the container increases in size copies of the value are used at new positions. More... | |
void | shrink (size_type count) |
Like resize but only shrinks the container. If the requested size of the vector is bigger than actual size, nothing happens. More... | |
void | swap (ptr_vector &other) |
Swaps two instances of pointer vector. More... | |
auto | operator<=> (const ext::ptr_vector< T > &second) const |
bool | operator== (const ptr_vector< T > &second) const |
Specialisation of equality operator for pointer vector. More... | |
Implementation of vector storing dynamicaly allocated instances of given type. The class mimicks the iterface of the standard library vector, but effectively allows polymorphic objects to be stored inside.
T | the type of stored values |
N | the size of the vector |
using ext::ptr_vector< T >::const_iterator = dereferencing_iterator < typename std::vector < T * >::const_iterator > |
The type of constant values iterator.
using ext::ptr_vector< T >::const_pointer = const T * |
The type of pointer to constant value.
using ext::ptr_vector< T >::const_reference = const value_type & |
The type of reference to constant values.
using ext::ptr_vector< T >::const_reverse_iterator = dereferencing_iterator < typename std::vector < T * >::const_reverse_iterator > |
The type of constant reverse values iterator.
using ext::ptr_vector< T >::diference_type = std::ptrdiff_t |
The type of size differences.
using ext::ptr_vector< T >::iterator = dereferencing_iterator < typename std::vector < T * >::iterator > |
The type of values iterator.
using ext::ptr_vector< T >::pointer = T * |
The type of pointer to values.
using ext::ptr_vector< T >::reference = value_type & |
The type of reference to values.
using ext::ptr_vector< T >::reverse_iterator = dereferencing_iterator < typename std::vector < T * >::reverse_iterator > |
The type of reverse values iterator.
using ext::ptr_vector< T >::size_type = std::size_t |
The type of sizes.
using ext::ptr_vector< T >::value_type = T |
The type of values.
|
defaultnoexcept |
The default constructor creating empty vector.
|
inline |
The constructor of the vecto from initializer list. The vector will store dynamically allocated copies of objects from inside of the initializer list.
R | the types stored inside the initializer list |
init | the initializer list |
|
inlineexplicit |
The constructor of the vector of specific size. Elements of the vector are defaultly constructed values of type R.
R | the actual type of values inside the constructed vector. |
count | the size of the constructed vector |
|
inline |
Constructor of the vector from range specified by iterators.
InputIt | the iterator type |
first | the begining of the range |
last | the end of the range |
|
inline |
Constructor from range of values.
Iterator | the type of range iterator |
range | the source range |
|
inline |
Constructor of the vector of size given by count
and filled with values from value
.
R | the actual type of value to fill with |
count | the size of the vector |
value | the value to fill the vector with |
|
inline |
Copy constrctor of the pointer vector.
other | the other instance |
|
inlinenoexcept |
Move constrctor of the pointer vector.
other | the other instance |
|
inlinenoexcept |
The destructor of the vector.
|
inline |
Sets the content of the vector to values in the given range.
InputIt | the iterator type |
first | the begining of the range |
last | the end of the range |
|
inline |
Sets the content of the vector to value copied count times.
R | the actual type of value to fill with |
count | the number how many time copy the value |
the | value to fill the container with |
|
inline |
Sets the content of the vector to values in the initializer list.
R | the types stored inside the initializer list |
ilist | the initializer list |
|
inline |
Getter of a reference to the value on given index.
index | the index to retrieve |
|
inline |
Getter of a reference to the value on given index.
index | the index to retrieve |
|
inline |
Getter of a value on the highest index.
|
inline |
Getter of a value on the highest index.
|
inlinenoexcept |
Move iterator to the begining of the values range in the vector.
|
inlinenoexcept |
Iterator to the begining of the values range in the vector.
|
inlinenoexcept |
Const iterator to the begining of the values range in the vector.
|
inlinenoexcept |
Returns the preallocated size of the vector.
|
inlinenoexcept |
Iterator to the begining of the values range in the vector.
|
inlinenoexcept |
Iterator one past the last element of the values range in the vector.
|
inlinenoexcept |
Removes all values from the vector.
|
inlinenoexcept |
Reverse iterator to the begining of the reversed range of values in the vector.
|
inlinenoexcept |
Reverse iterator one past the last element of the reversed range of values in the vector.
|
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.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
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.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
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.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
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.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
inline |
Appends a new value at the end of the container. The value is constructed inside the method using provided constructor parameters.
R | the actual type of appended value |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
Args | ... the types of arguments of the R constructor |
pos | the position to set |
args | ... the arguments of the R constructor |
|
inlinenoexcept |
Array emptines test.
|
inlinenoexcept |
Move iterator to the begining of the values range in the vector.
|
inlinenoexcept |
Iterator one past the last element of the values range in the vector.
|
inlinenoexcept |
Const iterator one past the last element of the values range in the vector.
|
inline |
Removes elements from the container in range given parameters first
and last
.
first | the begining of the removed range |
last | the end of the removed range |
|
inline |
Removes element from the container at position given by parameter pos
.
pos | the iterator pointing to the value to removed |
|
inline |
Removes elements from the container in range given parameters first
and last
.
first | the begining of the removed range |
last | the end of the removed range |
|
inline |
Removes element from the container at position given by parameter pos
.
pos | the iterator pointing to the value to removed |
|
inline |
Removes elements from the container in range given parameters first
and last
.
first | the begining of the removed range |
last | the end of the removed range |
|
inline |
Removes element from the container at position given by parameter pos
.
pos | the iterator pointing to the value to removed |
|
inline |
Removes elements from the container in range given parameters first
and last
.
first | the begining of the removed range |
last | the end of the removed range |
|
inline |
Removes element from the container at position given by parameter pos
.
pos | the iterator pointing to the value to removed |
|
inline |
Getter of a value on the lowest index.
|
inline |
Getter of a value on the lowest index.
|
inline |
Inserts the values from the given range to positions starting at given iterator pos
.
InputIt | the iterator type |
first | the begining of the range |
last | the end of the range |
|
inline |
Inserts the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
value | the value to insert |
|
inline |
Inserts the count
copies of value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
count | the number of copies to insert |
value | the value to insert |
|
inline |
Inserts the values from the given initializer list to positions starting at given iterator pos
.
R | the types stored inside the initializer list |
pos | the position to insert at |
ilist | the initializer list |
|
inline |
Inserts the values from the given range to positions starting at given iterator pos
.
InputIt | the iterator type |
first | the begining of the range |
last | the end of the range |
|
inline |
Inserts the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
value | the value to insert |
|
inline |
Inserts the count
copies of value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
count | the number of copies to insert |
value | the value to insert |
|
inline |
Inserts the values from the given initializer list to positions starting at given iterator pos
.
R | the types stored inside the initializer list |
pos | the position to insert at |
ilist | the initializer list |
|
inline |
Inserts the values from the given range to positions starting at given iterator pos
.
InputIt | the iterator type |
first | the begining of the range |
last | the end of the range |
|
inline |
Inserts the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
value | the value to insert |
|
inline |
Inserts the count
copies of value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
count | the number of copies to insert |
value | the value to insert |
|
inline |
Inserts the values from the given initializer list to positions starting at given iterator pos
.
R | the types stored inside the initializer list |
pos | the position to insert at |
ilist | the initializer list |
|
inline |
Inserts the values from the given range to positions starting at given iterator pos
.
InputIt | the iterator type |
first | the begining of the range |
last | the end of the range |
|
inline |
Inserts the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
value | the value to insert |
|
inline |
Inserts the count
copies of value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to insert at |
count | the number of copies to insert |
value | the value to insert |
|
inline |
Inserts the values from the given initializer list to positions starting at given iterator pos
.
R | the types stored inside the initializer list |
pos | the position to insert at |
ilist | the initializer list |
|
inlinenoexcept |
Returns the maximal number of values possible to store inside the container.
|
inline |
|
inline |
The copy operator of assignment.
other | the other instance |
|
inlinenoexcept |
The move operator of assignment.
other | the other instance |
|
inline |
Specialisation of equality operator for pointer vector.
T | the type of values inside the vector |
first | the first compared value |
second | the second compared value |
|
inline |
Array subscript operator.
index | the index to retrieve |
|
inline |
Array subscript operator.
index | the index to retrieve |
|
inline |
Removes element from the end of the container.
Appends a new value at the end of the container.
R | the actual type of appended value |
value | the appended value |
|
inline |
Make range of non-const begin to end iterators.
|
inline |
Make range of move begin to end iterators.
|
inline |
Make range of non-const begin to end iterators.
|
inlinenoexcept |
Reverse iterator to the begining of the reversed range of values in the vector.
|
inlinenoexcept |
Reverse iterator to the begining of the reversed range of values in the vector.
|
inlinenoexcept |
Reverse iterator one past the last element of the reversed range of values in the vector.
|
inlinenoexcept |
Reverse iterator one past the last element of the reversed range of values in the vector.
|
inline |
Prealocates space for given number of elements. Does not shrink the vector.
new_cap | the preallocated size of the vector |
|
inline |
Changes the size of the vector, allocates new elements if the size increases. The possibly needed values are defaultly constructed values of type R. The vector can both increase or decrease in size.
R | the type of the constructed values at possibly new indexes |
count | the requested new size of the vector |
|
inline |
Changes the size of the vector. If the container increases in size copies of the value
are used at new positions.
R | the actual type of the default value of new positions |
count | the requested new size of the vector |
value | the fill value of new positions |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to set |
value | the value to place to that position |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to set |
value | the value to place to that position |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to set |
value | the value to place to that position |
|
inline |
Changes the value on position given by iterator pos
.
R | the actual type of value stored inside the vector |
pos | the position to set |
value | the value to place to that position |
|
inline |
Like resize but only shrinks the container. If the requested size of the vector is bigger than actual size, nothing happens.
count | the requested new size of the vector |
|
inline |
Reallocates the vector to have the miniaml space overhead.
|
inlinenoexcept |
Getter of the vector size.
|
inline |
Swaps two instances of pointer vector.
x | the other instance to swap with |