xentara-utils v2.0.4
The Xentara Utility Library
|
A block of raw data. More...
#include <xentara/utils/core/RawVector.hpp>
Public Types | |
using | value_type = Element |
The element type. | |
using | allocator_type = Allocator |
The Allocator type. | |
using | size_type = typename std::allocator_traits< Allocator >::size_type |
The type used for sizes. | |
using | difference_type = typename std::allocator_traits< Allocator >::difference_type |
The type used for distances. | |
using | reference = value_type & |
A reference to an element. | |
using | const_reference = const value_type & |
A const reference to an element. | |
using | pointer = typename std::allocator_traits< Allocator >::pointer |
A pointer to an element. | |
using | const_pointer = typename std::allocator_traits< Allocator >::const_pointer |
A const pointer to an element. | |
using | iterator = ContiguousIterator< pointer, RawVector > |
An iterator. | |
using | const_iterator = ContiguousIterator< const_pointer, RawVector > |
A const iterator. | |
using | reverse_iterator = std::reverse_iterator< iterator > |
An iterator for iterating in reverse order. | |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
A const iterator for iterating in reverse order. | |
Public Member Functions | |
internal internal constexpr auto | operator= (std::initializer_list< Element > values) -> RawVector & |
Assignment operator for an initializer list. | |
constexpr auto | assign (size_type size, const Element &value) -> void |
Fills the vector with a certain value. | |
template<std::input_iterator InputIterator> | |
constexpr auto | assign (InputIterator first, InputIterator last) -> void |
Copies a range of elements. | |
constexpr auto | assign (std::initializer_list< Element > values) -> void |
Constructor that initializes the elements using an initializer list. | |
constexpr auto | get_allocator () const noexcept -> allocator_type |
Returns a copy of the allocator. | |
constexpr auto | operator== (const RawVector &rhs) const noexcept -> bool |
Equality operator. | |
constexpr auto | operator<=> (const RawVector &rhs) const noexcept -> std::compare_three_way_result_t< value_type > |
Three-Way-Comparison operator. | |
Constructors | |
constexpr | RawVector () noexcept(noexcept(Allocator()))=default |
Default constructor. | |
constexpr | RawVector (const Allocator &allocator) noexcept |
Constructor that sets the allocator. | |
constexpr | RawVector (size_type size, const Allocator &allocator=Allocator()) |
Constructor that creates an uninitialized vector of a certain size. | |
constexpr | RawVector (size_type size, const Element &value, const Allocator &allocator=Allocator()) |
Constructor that fills the vector with a certain value. | |
template<std::input_iterator InputIterator> | |
constexpr | RawVector (InputIterator first, InputIterator last, const Allocator &allocator=Allocator()) |
Constructor that copies a range of elements. | |
constexpr | RawVector (const RawVector &other, const Allocator &allocator) |
Constructor that copies the data but not the allocator. | |
constexpr | RawVector (RawVector &&other, const Allocator &allocator) |
Constructor that moves the data but not the allocator. | |
constexpr | RawVector (std::initializer_list< Element > values, const Allocator &allocator=Allocator()) |
Constructor that initializes the elements using an initializer list. | |
Element Access | |
constexpr auto | at (size_type index) const -> const_reference |
Accesses the element at a certain index. | |
constexpr auto | at (size_type index) -> reference |
Accesses the element at a certain index. | |
constexpr auto | operator[] (size_type index) const noexcept -> const_reference |
Subscript operator. | |
constexpr auto | operator[] (size_type index) noexcept -> reference |
Subscript operator. | |
constexpr auto | front () const noexcept -> const_reference |
Returns the first element. | |
constexpr auto | front () noexcept -> reference |
Returns the first element. | |
constexpr auto | back () const noexcept -> const_reference |
Returns the last element. | |
constexpr auto | back () noexcept -> reference |
Returns the last element. | |
constexpr auto | data () const noexcept -> const value_type * |
Raw access to the data. | |
constexpr auto | data () noexcept -> value_type * |
Raw access to the data. | |
Iterators | |
constexpr auto | begin () noexcept -> iterator |
Creates a begin iterator. | |
constexpr auto | begin () const noexcept -> const_iterator |
Creates a begin iterator. | |
constexpr auto | cbegin () const noexcept -> const_iterator |
Creates a begin iterator. | |
constexpr auto | end () noexcept -> iterator |
Creates an end iterator. | |
constexpr auto | end () const noexcept -> const_iterator |
Creates an end iterator. | |
constexpr auto | cend () const noexcept -> const_iterator |
Creates an end iterator. | |
constexpr auto | rbegin () noexcept -> reverse_iterator |
Creates a reverse begin iterator. | |
constexpr auto | rbegin () const noexcept -> const_reverse_iterator |
Creates a reverse begin iterator. | |
constexpr auto | crbegin () const noexcept -> const_reverse_iterator |
Creates a reverse begin iterator. | |
constexpr auto | rend () noexcept -> reverse_iterator |
Creates a reverse end iterator. | |
constexpr auto | rend () const noexcept -> const_reverse_iterator |
Creates a reverse end iterator. | |
constexpr auto | crend () const noexcept -> const_reverse_iterator |
Creates a reverse end iterator. | |
Capacity | |
constexpr auto | empty () const noexcept -> bool |
Determines whether the data is empty. | |
constexpr auto | size () const noexcept -> size_type |
Gets the size of the data. | |
constexpr auto | max_size () const noexcept -> size_type |
Gets the maximum possible data size. | |
constexpr auto | reserve (size_type capacity) -> void |
Increases the capacity of the vector. | |
constexpr auto | capacity () const noexcept -> size_type |
Gets the capacity of the data. | |
constexpr auto | shrink_to_fit () -> void |
Discards any unused capacity. | |
Modifiers | |
constexpr auto | clear () noexcept -> void |
Erases all elements. | |
constexpr auto | insert (const_iterator where, const Element &value) -> iterator |
Inserts an element at a certain position. | |
constexpr auto | insert (const_iterator where, Element &&value) -> iterator |
Move-Inserts an element at a certain position. | |
constexpr auto | insert (const_iterator where, size_type count, UninitializedTag tag) -> iterator |
Inserts a number of uninitialized elements at a certain position. | |
constexpr auto | insert (const_iterator where, size_type count, const Element &value) -> iterator |
Inserts a number of copies of a element at a certain position. | |
template<std::input_iterator InputIterator> | |
constexpr auto | insert (const_iterator where, InputIterator first, InputIterator last) -> iterator |
Inserts a range of values at a certain position. | |
constexpr auto | insert (const_iterator where, std::initializer_list< Element > values) -> iterator |
Inserts a list of values at a certain position. | |
template<typename... Arguments> | |
constexpr auto | emplace (const_iterator where, Arguments &&... arguments) -> iterator |
Creates an element at a certain position. | |
constexpr auto | erase (const_iterator position) -> iterator |
Removes an element from the vector. | |
constexpr auto | erase (const_iterator first, const_iterator last) -> iterator |
Removes a range of elements from the vector. | |
constexpr auto | push_back (const Element &value) -> void |
Appends an element to the back of the vector. | |
constexpr auto | push_back (Element &&value) -> void |
Move-Appends an element to the back of the vector. | |
template<typename... Arguments> | |
constexpr auto | emplace_back (Arguments &&... arguments) -> reference |
Appends a newly created element to the back of the vector. | |
constexpr auto | pop_back () -> void |
Removes the last element. | |
constexpr auto | resize (size_type newSize) -> void |
Resizes the vector. | |
constexpr auto | resize (size_type newSize, const value_type &fillValue) -> void |
Resizes the vector. | |
constexpr auto | swap (RawVector &other) noexcept -> void |
Swaps the contents of this vector with another vector. | |
A block of raw data.
This class behaves exactly like std::vector, but does not value-initialize new elements.
Element | The type for the elements. Must be a trivial type. |
Allocator | The type for the allocator. Allocator::construct() and Allocator::destroy() are not used. |
using xentara::utils::core::RawVector< Element, Allocator >::allocator_type = Allocator |
The Allocator type.
using xentara::utils::core::RawVector< Element, Allocator >::const_iterator = ContiguousIterator<const_pointer, RawVector> |
A const iterator.
using xentara::utils::core::RawVector< Element, Allocator >::const_pointer = typename std::allocator_traits<Allocator>::const_pointer |
A const pointer to an element.
using xentara::utils::core::RawVector< Element, Allocator >::const_reference = const value_type & |
A const reference to an element.
using xentara::utils::core::RawVector< Element, Allocator >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
A const iterator for iterating in reverse order.
using xentara::utils::core::RawVector< Element, Allocator >::difference_type = typename std::allocator_traits<Allocator>::difference_type |
The type used for distances.
using xentara::utils::core::RawVector< Element, Allocator >::iterator = ContiguousIterator<pointer, RawVector> |
An iterator.
using xentara::utils::core::RawVector< Element, Allocator >::pointer = typename std::allocator_traits<Allocator>::pointer |
A pointer to an element.
using xentara::utils::core::RawVector< Element, Allocator >::reference = value_type & |
A reference to an element.
using xentara::utils::core::RawVector< Element, Allocator >::reverse_iterator = std::reverse_iterator<iterator> |
An iterator for iterating in reverse order.
using xentara::utils::core::RawVector< Element, Allocator >::size_type = typename std::allocator_traits<Allocator>::size_type |
The type used for sizes.
using xentara::utils::core::RawVector< Element, Allocator >::value_type = Element |
The element type.
|
constexprdefaultnoexcept |
Default constructor.
Constructs an empty vector with a default constructed allocator.
|
explicitconstexprnoexcept |
Constructor that sets the allocator.
allocator | The allocator |
|
explicitconstexpr |
Constructor that creates an uninitialized vector of a certain size.
Creates a vector of the given size but leaves the elements uninitialized.
size | The number of entries to create room for |
allocator | The allocator |
|
constexpr |
Constructor that fills the vector with a certain value.
Creates a vector of the given size and fills it with the given value.
size | The number of entries to create |
value | The value to set the entries to |
allocator | The allocator |
|
constexpr |
Constructor that copies a range of elements.
Creates a vector that holds copies of the given input range.
first | The first element to copy |
last | The position after the last element to copy |
allocator | The allocator |
|
constexpr |
Constructor that copies the data but not the allocator.
Copies the data of another vector, but uses a different allocator
other | The vector to copy |
allocator | The allocator |
|
constexpr |
Constructor that moves the data but not the allocator.
Moves the data from another vector, but uses a different allocator
other | The vector to move |
allocator | The allocator |
|
constexpr |
Constructor that initializes the elements using an initializer list.
values | The values to initialize the elements to |
allocator | The allocator |
|
constexpr |
Copies a range of elements.
Replaces the contents of the vector with a given input range.
first | The first element to copy |
last | The position after the last element to copy |
|
constexpr |
Fills the vector with a certain value.
Resizes the vector to the given size and fills it with the given value.
size | The number of entries to create |
value | The value to set the entries to |
|
constexpr |
Constructor that initializes the elements using an initializer list.
Replaces the contents of the vector with the contents of an initializer list.
values | The initializer list |
|
constexpr |
Accesses the element at a certain index.
index | The index |
std::out_of_range | index is out of range |
|
constexpr |
Accesses the element at a certain index.
index | The index |
std::out_of_range | index is out of range |
|
constexprnoexcept |
Returns the last element.
|
constexprnoexcept |
Returns the last element.
|
constexprnoexcept |
Creates a begin iterator.
|
constexprnoexcept |
Creates a begin iterator.
|
constexprnoexcept |
Gets the capacity of the data.
|
constexprnoexcept |
Creates a begin iterator.
|
constexprnoexcept |
Creates an end iterator.
|
constexprnoexcept |
Erases all elements.
|
constexprnoexcept |
Creates a reverse begin iterator.
|
constexprnoexcept |
Creates a reverse end iterator.
|
constexprnoexcept |
Raw access to the data.
Returns a pointer to the underlying array that serves as element storage.
|
constexprnoexcept |
Raw access to the data.
Returns a pointer to the underlying array that serves as element storage.
|
constexpr |
Creates an element at a certain position.
where | The desired position of the new element. Must be a position within the vector, or cend() to append the element. |
arguments | The arguments to pass to the element's constructor |
|
constexpr |
Appends a newly created element to the back of the vector.
arguments | The arguments to pass to the element's constructor |
|
constexprnoexcept |
Determines whether the data is empty.
|
constexprnoexcept |
Creates an end iterator.
|
constexprnoexcept |
Creates an end iterator.
|
constexpr |
Removes a range of elements from the vector.
first | An iterator to the first element to remove |
last | An iterator one position past the last element to remove |
|
constexpr |
Removes an element from the vector.
position | The position of the element to remove. Must point to a valid element. |
|
constexprnoexcept |
Returns the first element.
|
constexprnoexcept |
Returns the first element.
|
constexprnoexcept |
Returns a copy of the allocator.
|
constexpr |
Inserts an element at a certain position.
where | The desired position of the new element. Must be a position within the vector, or cend() to append the element. |
value | The value to insert |
|
constexpr |
Move-Inserts an element at a certain position.
where | The desired position of the new element. Must be a position within the vector, or cend() to append the element. |
value | The value to move |
|
constexpr |
Inserts a range of values at a certain position.
where | The desired position of the first new element. Must be a position within the vector, or cend() to append the elements. |
first | An iterator to the first value to insert |
last | An iterator one position past the last value to insert |
|
constexpr |
Inserts a number of copies of a element at a certain position.
where | The desired position of the first new element. Must be a position within the vector, or cend() to append the elements. |
count | The number of copies to insert |
value | The value to insert |
|
constexpr |
Inserts a number of uninitialized elements at a certain position.
where | The desired position of the first new element. Must be a position within the vector, or cend() to append the elements. |
count | The number of elements to insert |
tag | Always pass kUninitialized as this parameter |
|
constexpr |
Inserts a list of values at a certain position.
where | The desired position of the first new element. Must be a position within the vector, or cend() to append the elements. |
values | The values to insert |
|
constexprnoexcept |
Gets the maximum possible data size.
|
constexprnoexcept |
Three-Way-Comparison operator.
Performs a lexicographical comparison of the elements of two vectors
|
constexpr |
Assignment operator for an initializer list.
values | The values to assign |
|
constexprnoexcept |
Equality operator.
Tests the contents of two vectors for equality
|
constexprnoexcept |
Subscript operator.
Returns a reference to the element at a certain index
index | The index |
|
constexprnoexcept |
Subscript operator.
Returns a reference to the element at a certain index
index | The index |
|
constexpr |
Removes the last element.
|
constexpr |
Appends an element to the back of the vector.
value | The value to insert |
|
constexpr |
Move-Appends an element to the back of the vector.
value | The value to move |
|
constexprnoexcept |
Creates a reverse begin iterator.
|
constexprnoexcept |
Creates a reverse begin iterator.
|
constexprnoexcept |
Creates a reverse end iterator.
|
constexprnoexcept |
Creates a reverse end iterator.
|
constexpr |
Increases the capacity of the vector.
Pre-Allocates storage for more data. Can be used to improve performance when repeatedly appending data. If capacity is less than or equal to the current capacity, the function does nothing.
capacity | The new capacity. |
|
constexpr |
Resizes the vector.
Grows or shrinks the vector to a new size. If the new size is greater than the old size, the new elements are left uninitialized.
newSize | The new size for the vector. |
|
constexpr |
Resizes the vector.
Grows or shrinks the vector to a new size. If the new size is greater than the old size, the new elements are filled with copies of fillValue.
newSize | The new size for the vector. |
fillValue | The value that should be used to initialize new element. |
|
constexpr |
Discards any unused capacity.
Reduces the allocated size so that the capacity is exactly enough to hold the data.
|
constexprnoexcept |
Gets the size of the data.
|
constexprnoexcept |
Swaps the contents of this vector with another vector.
other | The vector to swap with |