|
Flow
Documentation for the Flow C++ Library
|
#include <flow_vector.h>
Public Types | |
| using | value_type = T |
| using | reference = T& |
| using | const_reference = const T& |
| using | pointer = T* |
| using | const_pointer = const T* |
| using | iterator = T* |
| using | const_iterator = const T* |
| using | size_type = std::size_t |
| using | difference_type = std::ptrdiff_t |
| using | allocator_type = Allocator |
Public Member Functions | |
| constexpr | Vector () noexcept |
| Constructs an empty vector with default allocator and growth strategy. | |
| constexpr | Vector (const allocator_type &allocator) noexcept(noexcept(allocator_type(allocator))) |
| Constructs an empty vector with a specific allocator. | |
| constexpr | Vector (const Vector &rhs) |
| Copy-constructs a vector using the same allocator as the source. | |
| constexpr | Vector (const Vector &rhs, const allocator_type &allocator) |
| Copy-constructs a vector with a custom allocator. | |
| constexpr | Vector (Vector &&rhs) noexcept |
| Move-constructs a vector with the same allocator as the source. | |
| constexpr | Vector (Vector &&rhs, const allocator_type &allocator) |
| Move-constructs a vector with a custom allocator. | |
| template<std::input_iterator It> | |
| constexpr | Vector (It first, It last, const allocator_type &allocator={}) |
| Constructs a vector from an iterator range. | |
| constexpr | Vector (std::initializer_list< T > list, const allocator_type &allocator={}) |
| Constructs a vector from an initializer list. | |
| constexpr | Vector (std::size_t count, const allocator_type &allocator={}) |
| Constructs a vector with count default-initialized elements. | |
| constexpr | Vector (std::size_t count, const T &value, const allocator_type &allocator={}) |
| Constructs a vector with count copies of a given value. | |
| ~Vector () | |
| Vector & | operator= (Vector rhs) noexcept(std::is_nothrow_swappable_v< Vector >) |
| T & | operator[] (std::size_t i) noexcept |
| const T & | operator[] (std::size_t i) const noexcept |
| allocator_type | get_allocator () const noexcept |
| Returns the current allocator. | |
| iterator | begin () noexcept |
| constexpr const_iterator | begin () const noexcept |
| iterator | end () noexcept |
| constexpr const_iterator | end () const noexcept |
| constexpr std::size_t | size () const noexcept |
| Returns the number of elements in the vector. | |
| constexpr std::size_t | capacity () const noexcept |
| Returns the total allocated capacity. | |
| constexpr bool | empty () const noexcept |
| Checks whether the vector is empty. | |
| T & | front () noexcept |
| Returns a reference to the first element. | |
| constexpr const T & | front () const noexcept |
| Returns a reference to the first element. | |
| T & | back () noexcept |
| Returns a reference to the last element. | |
| constexpr const T & | back () const noexcept |
| Returns a reference to the last element. | |
| void | clear () noexcept |
| Clears the contents of the vector. | |
| void | reserve (std::size_t capacity) |
| Ensures the vector can hold at least the given capacity without reallocating. | |
| void | resize (std::size_t size) |
| Resizes the vector to contain the given number of default constructed elements. | |
| void | resize (std::size_t size, const T &value) |
| Resizes the vector and fills new elements with a given value. | |
| void | pushBack (const T &value) |
| Adds an element to the end of the vector. | |
| void | pushBack (T &&value) |
| Adds an element to the end of the vector. | |
| template<typename ... Args> | |
| void | emplaceBack (Args &&... args) |
| Constructs an element in-place at the end of the vector. | |
| void | popBack () noexcept |
| Removes the last element of the vector. | |
| iterator | erase (iterator pos) noexcept |
| Removes an element at the specified iterator position. | |
| iterator | erase (iterator first, iterator last) noexcept |
| Removes elements in the range [first, last). | |
| template<typename ... Args> | |
| void | emplace (iterator pos, Args &&... args) |
| Constructs an element in-place at the specified iterator position. | |
| void | insert (iterator pos, const T &value) |
| Inserts a copy of an element at the specified iterator position. | |
| void | insert (iterator pos, T &&value) |
| Inserts a moved element at the specified iterator position. | |
| void | insert (iterator pos, std::size_t count, const T &value) |
| Inserts multiple copies of a value at the specified position. | |
| template<std::input_iterator It> | |
| void | insert (iterator pos, It first, It last) |
| Inserts a range of elements at the specified position. Does not support self-insertion. | |
| void | insert (iterator pos, std::initializer_list< T > list) |
| Inserts an initializer list of elements at the specified position. | |
Private Types | |
| using | allocator_trait = std::allocator_traits<Allocator> |
Private Member Functions | |
| void | updateBuffer (T *buffer, std::size_t capacity) |
| void | relocateBuffer (std::size_t capacity) |
| void | relocateBufferWithHoles (std::size_t capacity, iterator pos, std::size_t holeSize) |
| template<typename ... U> | |
| void | resizeImp (std::size_t size, const U &... optionalValue) |
Private Attributes | |
| allocator_type | allocator_ |
| Strategy | growthStrategy_ |
| std::size_t | size_ |
| std::size_t | capacity_ |
| T * | buffer_ |
Friends | |
| void | swap (Vector &lhs, Vector &rhs) noexcept |
Definition at line 49 of file flow_vector.h.
|
private |
Definition at line 65 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::allocator_type = Allocator |
Definition at line 61 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::const_iterator = const T* |
Definition at line 57 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::const_pointer = const T* |
Definition at line 55 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::const_reference = const T& |
Definition at line 53 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::difference_type = std::ptrdiff_t |
Definition at line 59 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::iterator = T* |
Definition at line 56 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::pointer = T* |
Definition at line 54 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::reference = T& |
Definition at line 52 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::size_type = std::size_t |
Definition at line 58 of file flow_vector.h.
| using flow::Vector< T, Allocator, Strategy >::value_type = T |
Definition at line 51 of file flow_vector.h.
|
inlineconstexprnoexcept |
Constructs an empty vector with default allocator and growth strategy.
Definition at line 75 of file flow_vector.h.
|
inlineexplicitconstexprnoexcept |
Constructs an empty vector with a specific allocator.
| allocator | Memory allocator. |
Definition at line 81 of file flow_vector.h.
|
inlineconstexpr |
Copy-constructs a vector using the same allocator as the source.
| rhs | Source vector. |
Definition at line 92 of file flow_vector.h.
|
inlineconstexpr |
Copy-constructs a vector with a custom allocator.
| rhs | Source vector. |
| allocator | Memory allocator. |
Definition at line 99 of file flow_vector.h.
|
inlineconstexprnoexcept |
Move-constructs a vector with the same allocator as the source.
| rhs | Source vector. |
Definition at line 110 of file flow_vector.h.
|
inlineconstexpr |
Move-constructs a vector with a custom allocator.
| rhs | Source vector. |
| allocator | Memory allocator. |
Definition at line 117 of file flow_vector.h.
|
inlineexplicitconstexpr |
Constructs a vector from an iterator range.
| It | Input iterator. |
| first | Start of the range. |
| last | End of the range. |
| allocator | Memory allocator. |
Definition at line 137 of file flow_vector.h.
|
inlineconstexpr |
|
inlineexplicitconstexpr |
Constructs a vector with count default-initialized elements.
| count | Number of elements. |
| allocator | Memory allocator. |
Definition at line 156 of file flow_vector.h.
|
inlineexplicitconstexpr |
Constructs a vector with count copies of a given value.
| count | Number of elements. |
| value | Element value. |
| allocator | Memory allocator. |
Definition at line 169 of file flow_vector.h.
|
inline |
Definition at line 179 of file flow_vector.h.
|
inlineconstexprnoexcept |
|
inlinenoexcept |
Returns a reference to the last element.
Definition at line 257 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::emplace().
|
inlineconstexprnoexcept |
Definition at line 211 of file flow_vector.h.
|
inlinenoexcept |
Definition at line 207 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::erase(), flow::Vector< T, Allocator >::erase(), flow::Vector< T, Allocator >::insert(), flow::Vector< T, Allocator >::relocateBuffer(), flow::Vector< T, Allocator >::relocateBufferWithHoles(), and flow::Vector< T, Allocator >::Vector().
|
inlineconstexprnoexcept |
Returns the total allocated capacity.
Definition at line 231 of file flow_vector.h.
|
inlinenoexcept |
Clears the contents of the vector.
Definition at line 270 of file flow_vector.h.
|
inline |
Constructs an element in-place at the specified iterator position.
| pos | Insertion position. |
| ...args | Arguments to forward. |
Definition at line 357 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::insert(), and flow::Vector< T, Allocator >::insert().
|
inline |
Constructs an element in-place at the end of the vector.
| ...args | Arguments to forward. |
Definition at line 314 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::emplace(), flow::Vector< T, Allocator >::pushBack(), and flow::Vector< T, Allocator >::pushBack().
|
inlineconstexprnoexcept |
Checks whether the vector is empty.
Definition at line 237 of file flow_vector.h.
|
inlineconstexprnoexcept |
Definition at line 219 of file flow_vector.h.
|
inlinenoexcept |
Definition at line 215 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::emplace(), flow::Vector< T, Allocator >::erase(), flow::Vector< T, Allocator >::erase(), flow::Vector< T, Allocator >::insert(), flow::Vector< T, Allocator >::relocateBuffer(), flow::Vector< T, Allocator >::relocateBufferWithHoles(), and flow::Vector< T, Allocator >::Vector().
|
inlinenoexcept |
Removes elements in the range [first, last).
| first | Start of range. |
| last | End of range. |
Definition at line 343 of file flow_vector.h.
|
inlinenoexcept |
Removes an element at the specified iterator position.
| pos | Iterator to the element to remove. |
Definition at line 332 of file flow_vector.h.
|
inlineconstexprnoexcept |
Returns a reference to the first element.
Definition at line 250 of file flow_vector.h.
|
inlinenoexcept |
Returns a reference to the first element.
Definition at line 243 of file flow_vector.h.
|
inlinenoexcept |
|
inline |
Inserts a copy of an element at the specified iterator position.
| pos | Insertion position. |
| value | Value to insert. |
Definition at line 383 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::insert(), and flow::Vector< T, Allocator >::insert().
|
inline |
Inserts a range of elements at the specified position. Does not support self-insertion.
| It | Input iterator. |
| pos | Insertion position. |
| first | Start of range. |
| last | End of range. |
Definition at line 409 of file flow_vector.h.
|
inline |
Inserts an initializer list of elements at the specified position.
| pos | Insertion position. |
| list | Elements to insert. |
Definition at line 453 of file flow_vector.h.
|
inline |
Inserts multiple copies of a value at the specified position.
| pos | Insertion position. |
| count | Number of copies. |
| value | Value to insert. |
Definition at line 398 of file flow_vector.h.
|
inline |
|
inlinenoexcept |
Definition at line 184 of file flow_vector.h.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Removes the last element of the vector.
Definition at line 323 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::erase().
|
inline |
Adds an element to the end of the vector.
| value | Element to add. |
Definition at line 298 of file flow_vector.h.
|
inline |
Adds an element to the end of the vector.
| value | Element to add. |
Definition at line 307 of file flow_vector.h.
|
inlineprivate |
Definition at line 467 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::emplaceBack(), flow::Vector< T, Allocator >::reserve(), and flow::Vector< T, Allocator >::resizeImp().
|
inlineprivate |
Definition at line 476 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::emplace(), and flow::Vector< T, Allocator >::insert().
|
inline |
Ensures the vector can hold at least the given capacity without reallocating.
| capacity | Desired minimum capacity. |
Definition at line 277 of file flow_vector.h.
|
inline |
Resizes the vector to contain the given number of default constructed elements.
| size | New size. |
Definition at line 285 of file flow_vector.h.
|
inline |
Resizes the vector and fills new elements with a given value.
| size | New size. |
| value | Value to fill. |
Definition at line 292 of file flow_vector.h.
|
inlineprivate |
Definition at line 486 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::resize(), and flow::Vector< T, Allocator >::resize().
|
inlineconstexprnoexcept |
Returns the number of elements in the vector.
Definition at line 225 of file flow_vector.h.
|
inlineprivate |
Definition at line 459 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::relocateBuffer(), and flow::Vector< T, Allocator >::relocateBufferWithHoles().
|
friend |
Definition at line 503 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::operator=(), and flow::Vector< T, Allocator >::swap.
|
private |
Definition at line 67 of file flow_vector.h.
|
private |
Definition at line 71 of file flow_vector.h.
|
private |
Definition at line 70 of file flow_vector.h.
|
private |
Definition at line 68 of file flow_vector.h.
Referenced by flow::Vector< T, Allocator >::emplace(), flow::Vector< T, Allocator >::emplaceBack(), and flow::Vector< T, Allocator >::insert().
|
private |
Definition at line 69 of file flow_vector.h.