General Utility Library for C++14
2.12
|
A resizable container with contiguous storage that can hold a specified number of elements without allocating memory on the heap.
A SmallVector is very similar to a std::vector, but it can store a small number of elements within the object itself, similar to a std::array. If the number of elements exceeds this inner capacity (size() > inner_capacity()), the elements are stored on the heap as in a conventional std::vector.
SmallVector mimicks the API of std::vector closely, but it does not support allocators. It also uses 32-bit integers for storing the number of elements and capacity. On 64-bit systems, this makes the object slightly more memory efficient and lets it store less elements.
ElementT | Type of the elements to be stored in the container |
in_capacity | The number of elements that can be stored directly in the object without allocating (the "inner capacity") |
Construction & destruction | |
---|---|
SmallVector() | Construct an empty SmallVector |
SmallVector(SizeType) | Construct a SmallVector that is filled with a certain number of default-initialized elements |
SmallVector(SizeType, const ValueType&) | Construct a SmallVector that is filled with a certain number of copies of the given value |
SmallVector(InputIterator, InputIterator) | Construct a SmallVector that is filled with copies of elements from the given range |
SmallVector(const SmallVector&) | Copy constructor |
SmallVector(SmallVector&&) | Move constructor |
SmallVector(std::initializer_list<ValueType>) | Construct a SmallVector from an initializer list |
~SmallVector() | Destructor |
Assignment | |
assign(SizeType, const ValueType&) | Assign a certain number of copies of the given value |
assign(InputIterator, InputIterator) | Assign copies of the elements from the given range |
assign(std::initializer_list<ValueType>) | Assign the contents of an initializer list |
operator=(SmallVector const&) | Copy assignment |
operator=(SmallVector&&) | Move assignment |
operator=(std::initializer_list<ValueType>) | Assign the contents of an initializer list |
Element access | |
operator[](SizeType) | Access an element by index without bounds-checking |
at(SizeType) | Access an element by index with bounds-checking |
front(), back() | Access the first/last element |
data() | Return a pointer to the contiguous data storage |
Iterators | |
begin(), cbegin() | Return an iterator to the first element |
end(), cend() | Return an iterator past the last element |
rbegin(), crbegin() | Return an iterator to the first element of the reversed vector |
rend(), crend() | Return an iterator past the last element of the reversed vector |
Size & capacity | |
capacity() | Return the number of elements that can currently be stored without allocating more memory |
empty() | Determine if the vector is empty |
inner_capacity() | Return the number of elements that can be stored internally without allocating heap memory |
max_size() | Return the maximum number of elements that can theoretically be stored |
reserve(SizeType) | Increase the capacity of the vector to the specified size |
resize(SizeType) | Change the number of elements, filling up with default-constructed elements if necessary |
resize(SizeType, const ValueType&) | Change the number of elements, filling up with copy-constructed elements if necessary |
shrink_to_fit() | Reduce the capacity as far as possible while retaining all stored elements |
size() | Return the number of elements that are currently stored |
Content modification | |
clear() | Erase all elements without changing capacity |
emplace(ConstIterator, ArgumentTypes&&...) | Construct an additional element at an arbitrary position |
emplace_back(ArgumentTypes&&...) | Construct an additional element at the end |
erase(ConstIterator) | Erase a single element |
erase(ConstIterator, ConstIterator) | Erase a range of elements |
insert(ConstIterator, const ValueType&) | Copy-insert a single element |
insert(ConstIterator, ValueType&&) | Move-insert a single element |
insert(ConstIterator, SizeType, const ValueType&) | Insert a number of copies of a given value |
insert(ConstIterator, InputIterator, InputIterator) | Insert a range of values |
insert(ConstIterator, std::initializer_list<ValueType>) | Insert elements from an initializer list |
pop_back() | Remove the last element |
push_back(const ValueType&) | Copy-insert one element at the end |
push_back(ValueType&&) | Move-insert one element at the end |
swap(SmallVector&) | Exchange the contents of this SmallVector with those of another one |
operator==(const SmallVector&, const SmallVector&) | Return true if both vectors have the same size() and the same elements |
operator!=(const SmallVector&, const SmallVector&) | Return true if both vectors have a different size() or at least one different element |
swap(SmallVector&, SmallVector&) | Exchange the contents two SmallVectors |
Member types are available in both CamelCase and snake_case. | ||
ValueType | value_type | Type of the elements in the underlying container |
SizeType | size_type | Unsigned integer type for indexing, number of elements, capacity |
DifferenceType | difference_type | Signed integer type for storing the difference of two iterators |
Reference | reference | Reference to an element |
ConstReference | const_reference | Reference to a const element |
Iterator | iterator | Iterator to an element |
ConstIterator | const_iterator | Iterator to a const element |
ReverseIterator | reverse_iterator | Iterator to an element in reversed container |
ConstReverseIterator | const_reverse_iterator | Iterator to a const element in reversed container |
#include <SmallVector.h>
Public Types | |
using | ValueType = ElementT |
Type of the elements in the underlying container. | |
using | value_type = ValueType |
Type of the elements in the underlying container. More... | |
using | SizeType = uint32_t |
Unsigned integer type for indexing, number of elements, capacity. | |
using | size_type = SizeType |
Unsigned integer type for indexing, number of elements, capacity. More... | |
using | DifferenceType = std::ptrdiff_t |
Signed integer type for the difference of two iterators. | |
using | difference_type = DifferenceType |
Signed integer type for the difference of two iterators. More... | |
using | Reference = ValueType & |
Reference to an element. | |
using | reference = Reference |
Reference to an element. More... | |
using | ConstReference = const ValueType & |
Reference to a const element. | |
using | const_reference = ConstReference |
Reference to a const element. More... | |
using | Iterator = ValueType * |
Iterator to an element. | |
using | iterator = Iterator |
Iterator to an element. More... | |
using | ConstIterator = const ValueType * |
Iterator to a const element. | |
using | const_iterator = ConstIterator |
Iterator to a const element. More... | |
using | ReverseIterator = std::reverse_iterator< Iterator > |
Iterator to an element in reversed container. | |
using | reverse_iterator = ReverseIterator |
Iterator to an element in reversed container. More... | |
using | ConstReverseIterator = std::reverse_iterator< ConstIterator > |
Iterator to a const element in reversed container. | |
using | const_reverse_iterator = ConstReverseIterator |
Iterator to a const element in reversed container. More... | |
Public Member Functions | |
SmallVector () noexcept=default | |
Construct an empty SmallVector. More... | |
SmallVector (SizeType num_elements) | |
Construct a SmallVector that is filled with a certain number of default-initialized elements. More... | |
SmallVector (SizeType num_elements, const ValueType &value) | |
Construct a SmallVector that is filled with a certain number of copies of the given value. More... | |
template<class InputIterator , typename = std::enable_if_t<not std::is_integral<InputIterator>::value>> | |
SmallVector (InputIterator first, InputIterator last) | |
Construct a SmallVector that is filled with copies of elements from the given range. More... | |
SmallVector (const SmallVector &other) noexcept(std::is_nothrow_copy_constructible< ValueType >::value) | |
Create a copy of another SmallVector with the same inner capacity. More... | |
SmallVector (SmallVector &&other) noexcept(std::is_nothrow_move_constructible< ValueType >::value) | |
Move constructor: Create a SmallVector from the contents of another one with the same inner capacity using move semantics. More... | |
SmallVector (std::initializer_list< ValueType > init) | |
Construct a SmallVector that is filled with copies of the elements from a given initializer list. More... | |
~SmallVector () | |
Destructor: Destroys all stored elements and frees all allocated memory. | |
void | assign (SizeType num_elements, const ValueType &value) |
Fill the vector with a certain number of copies of the given value after clearing all previous contents. More... | |
template<class InputIterator , typename = std::enable_if_t<not std::is_integral<InputIterator>::value>> | |
void | assign (InputIterator first, InputIterator last) |
Fill the vector with copies of elements from the given range. More... | |
void | assign (std::initializer_list< ValueType > init) |
Assign the elements of an initializer list to this vector after clearing all previous contents. More... | |
constexpr Reference | at (SizeType idx) |
Return a reference to the element at the specified index with bounds-checking. More... | |
constexpr ConstReference | at (SizeType idx) const |
Return a const reference to the element at the specified index. | |
constexpr Reference | back () noexcept |
Return a reference to the last element in the vector. More... | |
constexpr ConstReference | back () const noexcept |
Return a const reference to the last element in the vector. More... | |
constexpr Iterator | begin () noexcept |
Return an iterator to the first element of the vector. More... | |
constexpr ConstIterator | begin () const noexcept |
Return a const iterator to the first element of the vector. More... | |
constexpr SizeType | capacity () const noexcept |
Return the number of elements that can currently be stored in this vector without having to allocate more memory. | |
constexpr ConstIterator | cbegin () const noexcept |
Return a const iterator to the first element of the vector. More... | |
constexpr ConstIterator | cend () const noexcept |
Return a const iterator pointing past the last element of the vector. More... | |
void | clear () noexcept |
Erase all elements from the container without changing its capacity. More... | |
ConstReverseIterator | crbegin () noexcept |
Return a const reverse iterator to the first element of the reversed vector (which is the last element of the actual vector). More... | |
ConstReverseIterator | crend () noexcept |
Return a const reverse iterator pointing past the last element of the reversed vector. More... | |
constexpr ValueType * | data () noexcept |
Return a pointer to the contiguous data storage of the vector. More... | |
constexpr const ValueType * | data () const noexcept |
Return a pointer to the contiguous data storage of the vector. More... | |
template<typename... ArgumentTypes> | |
Iterator | emplace (ConstIterator pos, ArgumentTypes &&... arguments) |
Construct an additional element at an arbitrary position in the vector. More... | |
template<typename... ArgumentTypes> | |
Reference | emplace_back (ArgumentTypes &&... arguments) |
Construct an additional element at the end of the buffer. More... | |
constexpr bool | empty () const noexcept |
Determine if the vector is empty. | |
constexpr Iterator | end () noexcept |
Return an iterator pointing past the last element of the vector. More... | |
constexpr ConstIterator | end () const noexcept |
Return a const iterator pointing past the last element of the vector. More... | |
Iterator | erase (ConstIterator pos) |
Erase a single element from the vector, moving elements behind it forward. More... | |
Iterator | erase (ConstIterator first, ConstIterator last) |
Erase a range of elements from the vector, moving elements behind the range forward. More... | |
constexpr Reference | front () noexcept |
Return a reference to the first element in the vector. More... | |
constexpr ConstReference | front () const noexcept |
Return a const reference to the first element in the vector. More... | |
constexpr SizeType | inner_capacity () const noexcept |
Return the number of elements this SmallVector can hold internally without having to allocate storage. | |
Iterator | insert (ConstIterator pos, const ValueType &value) |
Insert a single element before the indicated position. More... | |
Iterator | insert (ConstIterator pos, ValueType &&value) |
Insert a single element before the indicated position. More... | |
Iterator | insert (ConstIterator pos, SizeType num_elements, const ValueType &value) |
Insert a number of copies of the given value before the indicated position. More... | |
template<class InputIterator , typename = std::enable_if_t<not std::is_integral<InputIterator>::value>> | |
Iterator | insert (ConstIterator pos, InputIterator first, InputIterator last) |
Insert a range of values before the indicated position. More... | |
Iterator | insert (ConstIterator pos, std::initializer_list< ValueType > init) |
Insert elements from an initializer list before the indicated position. More... | |
constexpr SizeType | max_size () const noexcept |
Return the maximum number of elements that this vector can theoretically hold. More... | |
SmallVector & | operator= (const SmallVector &other) noexcept(std::is_nothrow_copy_assignable< ValueType >::value) |
Copy assignment operator: Copy all elements from another SmallVector after clearing all previous contents. More... | |
SmallVector & | operator= (SmallVector &&other) noexcept(std::is_nothrow_move_constructible< ValueType >::value) |
Move assignment operator: Assign all of the elements from another vector to this one using move semantics after clearing all previous contents. More... | |
SmallVector & | operator= (std::initializer_list< ValueType > init) |
Assign the elements of an initializer list to this vector after clearing all previous contents. | |
constexpr Reference | operator[] (SizeType idx) |
Return a reference to the element at the specified index. | |
constexpr ConstReference | operator[] (SizeType idx) const |
Return a const reference to the element at the specified index. | |
void | pop_back () |
Remove the last element from the vector. More... | |
void | push_back (const ValueType &value) |
Copy one element to the end of the buffer. More... | |
void | push_back (ValueType &&value) |
Move one element to the end of the buffer. More... | |
ReverseIterator | rbegin () noexcept |
Return a reverse iterator to the first element of the reversed vector (which is the last element of the actual vector). More... | |
ReverseIterator | rend () noexcept |
Return a reverse iterator pointing past the last element of the reversed vector. More... | |
void | reserve (SizeType new_capacity) |
Increase the capacity of the vector to the specified size. More... | |
void | resize (SizeType num_elements) |
Change the number of elements in the container. More... | |
void | resize (SizeType num_elements, const ValueType &element) |
Change the number of elements in the container. More... | |
void | shrink_to_fit () |
Reduce the capacity as far as possible while retaining all stored elements. More... | |
constexpr SizeType | size () const noexcept |
Return the number of elements that are currently stored. | |
void | swap (SmallVector &other) |
Exchange the contents of this SmallVector with those of another one. More... | |
Friends | |
bool | operator== (const SmallVector &lhs, const SmallVector &rhs) |
Equality operator: Return true if both vectors have the same size() and the same elements. More... | |
bool | operator!= (const SmallVector &lhs, const SmallVector &rhs) |
Inequality operator: Return true if both vectors have a different size() or at least one different element. More... | |
using gul14::SmallVector< ElementT, in_capacity >::const_iterator = ConstIterator |
Iterator to a const element.
using gul14::SmallVector< ElementT, in_capacity >::const_reference = ConstReference |
Reference to a const element.
using gul14::SmallVector< ElementT, in_capacity >::const_reverse_iterator = ConstReverseIterator |
Iterator to a const element in reversed container.
using gul14::SmallVector< ElementT, in_capacity >::difference_type = DifferenceType |
Signed integer type for the difference of two iterators.
using gul14::SmallVector< ElementT, in_capacity >::iterator = Iterator |
Iterator to an element.
using gul14::SmallVector< ElementT, in_capacity >::reference = Reference |
Reference to an element.
using gul14::SmallVector< ElementT, in_capacity >::reverse_iterator = ReverseIterator |
Iterator to an element in reversed container.
using gul14::SmallVector< ElementT, in_capacity >::size_type = SizeType |
Unsigned integer type for indexing, number of elements, capacity.
using gul14::SmallVector< ElementT, in_capacity >::value_type = ValueType |
Type of the elements in the underlying container.
|
defaultnoexcept |
Construct an empty SmallVector.
If the template argument is zero, a SmallVector based on std::vector with a capacity of zero elements is generated. Use the SmallVector(size_type) constructor or call the resize() function afterwards to get a SmallVector based on std::vector with nonzero capacity.
|
inlineexplicit |
Construct a SmallVector that is filled with a certain number of default-initialized elements.
num_elements | The number of initial elements |
References gul14::SmallVector< ElementT, in_capacity >::data(), and gul14::SmallVector< ElementT, in_capacity >::reserve().
|
inline |
Construct a SmallVector that is filled with a certain number of copies of the given value.
num_elements | The number of initial elements |
value | The value to be copied to the initial elements |
|
inline |
Construct a SmallVector that is filled with copies of elements from the given range.
This constructor is not available if the iterators are of integral (and non-pointer) type, in order to avoid confusion with SmallVector(SizeType num_elements, const ValueType& value).
InputIterator | An input iterator type |
first | Iterator to the first element to be copied |
last | Iterator past the last element to be copied |
|
inlinenoexcept |
Create a copy of another SmallVector with the same inner capacity.
The new vector is filled with copies of the original data elements. It has the same size() as the original, but its capacity() might differ.
|
inlinenoexcept |
Move constructor: Create a SmallVector from the contents of another one with the same inner capacity using move semantics.
The new vector has the same size() as the original, but its capacity() might differ. The original vector is empty() after the operation.
If the other vector has allocated storage, it is efficiently moved in en-bloc. If it uses the internal storage, the behavior depends on the availability of a non-throwing move constructor. If such a noexcept
move constructor is available, elements are moved in one-by-one. Otherwise, elements are copied in.
If no exception is thrown, the other vector is guaranteed to be empty after the call. If an exception is thrown, it is guaranteed to be unchanged if ValueType is either copy-constructible or nothrow-move-constructible.
|
inline |
Construct a SmallVector that is filled with copies of the elements from a given initializer list.
|
inline |
Fill the vector with copies of elements from the given range.
This overload is not available if the iterators are of integral (and non-pointer) type, in order to avoid confusion with assign(SizeType num_elements, const ValueType& value).
InputIterator | An input iterator type |
first | Iterator to the first element to be copied |
last | Iterator past the last element to be copied |
std::vector
, SmallVector::assign()
does not allow narrowing conversions.References gul14::SmallVector< ElementT, in_capacity >::clear().
|
inline |
Fill the vector with a certain number of copies of the given value after clearing all previous contents.
num_elements | The number of initial elements |
value | The value to be copied into the vector |
References gul14::SmallVector< ElementT, in_capacity >::clear().
Referenced by gul14::SmallVector< ElementT, in_capacity >::operator=().
|
inline |
Assign the elements of an initializer list to this vector after clearing all previous contents.
References gul14::SmallVector< ElementT, in_capacity >::clear(), gul14::SmallVector< ElementT, in_capacity >::data(), and gul14::SmallVector< ElementT, in_capacity >::reserve().
|
inlineconstexpr |
Return a reference to the element at the specified index with bounds-checking.
std::out_of_range | is thrown if idx >= size() |
References gul14::cat(), and gul14::SmallVector< ElementT, in_capacity >::data().
|
inlineconstexprnoexcept |
Return a const reference to the last element in the vector.
The behavior is undefined if the vector is empty.
|
inlineconstexprnoexcept |
Return a reference to the last element in the vector.
The behavior is undefined if the vector is empty.
Referenced by gul14::SmallVector< ElementT, in_capacity >::emplace_back().
|
inlineconstexprnoexcept |
Return a const iterator to the first element of the vector.
If the vector is empty, this iterator cannot be dereferenced.
References gul14::SmallVector< ElementT, in_capacity >::data().
|
inlineconstexprnoexcept |
Return an iterator to the first element of the vector.
If the vector is empty, this iterator cannot be dereferenced.
References gul14::SmallVector< ElementT, in_capacity >::data().
Referenced by gul14::SmallVector< ElementT, in_capacity >::cbegin(), gul14::SmallVector< ElementT, in_capacity >::crend(), gul14::SmallVector< ElementT, in_capacity >::insert(), and gul14::SmallVector< ElementT, in_capacity >::rend().
|
inlineconstexprnoexcept |
Return a const iterator to the first element of the vector.
If the vector is empty, this iterator cannot be dereferenced.
References gul14::SmallVector< ElementT, in_capacity >::begin().
|
inlineconstexprnoexcept |
Return a const iterator pointing past the last element of the vector.
This iterator cannot be dereferenced.
References gul14::SmallVector< ElementT, in_capacity >::end().
Referenced by gul14::SmallVector< ElementT, in_capacity >::emplace().
|
inlinenoexcept |
Erase all elements from the container without changing its capacity.
The size() is zero after this call.
References gul14::SmallVector< ElementT, in_capacity >::data().
Referenced by gul14::SmallVector< ElementT, in_capacity >::assign(), gul14::SmallVector< ElementT, in_capacity >::operator=(), and gul14::SmallVector< ElementT, in_capacity >::~SmallVector().
|
inlinenoexcept |
Return a const reverse iterator to the first element of the reversed vector (which is the last element of the actual vector).
The iterator cannot be dereferenced if the vector is empty.
References gul14::SmallVector< ElementT, in_capacity >::end().
|
inlinenoexcept |
Return a const reverse iterator pointing past the last element of the reversed vector.
The iterator cannot be dereferenced if the vector is empty.
References gul14::SmallVector< ElementT, in_capacity >::begin().
|
inlineconstexprnoexcept |
Return a pointer to the contiguous data storage of the vector.
If the vector is empty, the pointer is not dereferencable.
|
inlineconstexprnoexcept |
Return a pointer to the contiguous data storage of the vector.
If the vector is empty, the pointer is not dereferencable.
Referenced by gul14::SmallVector< ElementT, in_capacity >::assign(), gul14::SmallVector< ElementT, in_capacity >::at(), gul14::SmallVector< ElementT, in_capacity >::begin(), gul14::SmallVector< ElementT, in_capacity >::clear(), gul14::SmallVector< ElementT, in_capacity >::front(), gul14::SmallVector< ElementT, in_capacity >::operator=(), gul14::SmallVector< ElementT, in_capacity >::operator[](), gul14::SmallVector< ElementT, in_capacity >::reserve(), gul14::SmallVector< ElementT, in_capacity >::resize(), gul14::SmallVector< ElementT, in_capacity >::shrink_to_fit(), and gul14::SmallVector< ElementT, in_capacity >::SmallVector().
|
inline |
Construct an additional element at an arbitrary position in the vector.
The new element is inserted at the position indicated by pos; pre-existing elements at and after this position are moved backwards. Other parameters of emplace() are passed to the element constructor via perfect forwarding.
If pos == end(), the new element is constructed in-place at the end of the vector. Otherwise, it is first constructed on the stack and then move-assigned into the vector. If the constructor of the new element throws, the contents of the vector are not changed, but the capacity might differ.
All existing iterators are invalidated if the new size() exceeds the original capacity(). Otherwise, only the iterators to elements at or after pos are invalidated.
pos | Constant iterator to the position at which the new element should be constructed. |
arguments | List of arguments for the element constructor. |
std::length_error | is thrown if the maximum capacity of the container is reached and cannot be increased. |
References gul14::SmallVector< ElementT, in_capacity >::cend(), and gul14::SmallVector< ElementT, in_capacity >::emplace_back().
|
inline |
Construct an additional element at the end of the buffer.
The parameters of emplace_back() are passed to the element constructor via perfect forwarding. If the constructor of the new element throws, the contents of the vector are not changed, but the capacity might differ.
All existing iterators are invalidated if the new size() exceeds the original capacity(). Otherwise, only the end() iterator is invalidated.
arguments | List of arguments for the element constructor. |
std::length_error | is thrown if the maximum capacity of the container is reached and cannot be increased. |
References gul14::SmallVector< ElementT, in_capacity >::back().
Referenced by gul14::SmallVector< ElementT, in_capacity >::emplace().
|
inlineconstexprnoexcept |
Return a const iterator pointing past the last element of the vector.
This iterator cannot be dereferenced.
|
inlineconstexprnoexcept |
Return an iterator pointing past the last element of the vector.
This iterator cannot be dereferenced.
Referenced by gul14::SmallVector< ElementT, in_capacity >::cend(), gul14::SmallVector< ElementT, in_capacity >::crbegin(), gul14::SmallVector< ElementT, in_capacity >::erase(), and gul14::SmallVector< ElementT, in_capacity >::rbegin().
|
inline |
Erase a range of elements from the vector, moving elements behind the range forward.
This call does not change the capacity. Iterators pointing at or after the deleted range are invalidated.
first | Iterator to the first element to be erased. |
last | Iterator past the last element to be erased. |
last
is returned. References gul14::SmallVector< ElementT, in_capacity >::end().
|
inline |
Erase a single element from the vector, moving elements behind it forward.
This call does not change the capacity. Iterators pointing at or after the deleted element are invalidated.
pos | Iterator to the element to be erased. This iterator must be dereferenceable, so end() is not allowed. |
|
inlineconstexprnoexcept |
Return a const reference to the first element in the vector.
The behavior is undefined if the vector is empty.
References gul14::SmallVector< ElementT, in_capacity >::data().
|
inlineconstexprnoexcept |
Return a reference to the first element in the vector.
The behavior is undefined if the vector is empty.
References gul14::SmallVector< ElementT, in_capacity >::data().
|
inline |
Insert a single element before the indicated position.
This increases the size of the container by 1. All elements starting from the indicated position are moved backwards.
pos | Iterator to the existing element in front of which the new value should be inserted. |
value | The value to be copied into the container. |
Referenced by gul14::SmallVector< ElementT, in_capacity >::insert().
|
inline |
Insert a range of values before the indicated position.
This overload is not available if the iterators are of integral (and non-pointer) type, in order to avoid confusion with insert(ConstIterator pos, SizeType num_elements, const ValueType& value).
InputIterator | An input iterator type. |
pos | Iterator to the existing element in front of which the new values should be inserted. |
first | Iterator to the first element to be copied. |
last | Iterator pointing past the last element to be copied. |
References gul14::SmallVector< ElementT, in_capacity >::begin().
|
inline |
Insert a number of copies of the given value before the indicated position.
pos | Iterator to the existing element in front of which the new value should be inserted. |
num_elements | The number of elements to be inserted. |
value | The value to be moved into the container. |
References gul14::SmallVector< ElementT, in_capacity >::begin().
|
inline |
Insert elements from an initializer list before the indicated position.
pos | Iterator to the existing element in front of which the new values should be inserted. |
init | An initializer list with the values to be copied. |
References gul14::SmallVector< ElementT, in_capacity >::insert().
|
inline |
Insert a single element before the indicated position.
This increases the size of the container by 1. All elements starting from the indicated position are moved backwards.
pos | Iterator to the existing element in front of which the new value should be inserted. |
value | The value to be moved into the container. |
|
inlineconstexprnoexcept |
Return the maximum number of elements that this vector can theoretically hold.
This value reflects only limitations of the implementation. It is possible that the size of the container is effectively limited to a much smaller value because of limited available memory.
|
inlinenoexcept |
Copy assignment operator: Copy all elements from another SmallVector after clearing all previous contents.
References gul14::SmallVector< ElementT, in_capacity >::clear(), gul14::SmallVector< ElementT, in_capacity >::data(), and gul14::SmallVector< ElementT, in_capacity >::reserve().
|
inlinenoexcept |
Move assignment operator: Assign all of the elements from another vector to this one using move semantics after clearing all previous contents.
If the other vector has allocated storage, it is efficiently moved in en-bloc. If it uses the internal storage, the behavior depends on the availability of a non-throwing move constructor. If such a noexcept
move constructor is available, elements are moved in one-by-one. Otherwise, elements are copied in.
If no exception is thrown, the other vector is guaranteed to be empty after the call. If an exception is thrown, it is guaranteed to be unchanged if ValueType is either copy-constructible or nothrow-move-constructible.
References gul14::SmallVector< ElementT, in_capacity >::clear().
|
inline |
Remove the last element from the vector.
Calling pop_back() on an empty vector results in undefined behavior.
|
inline |
Copy one element to the end of the buffer.
All existing iterators are invalidated if the new size() exceeds the original capacity(). Otherwise, only the end() iterator is invalidated.
std::length_error | is thrown if the maximum capacity of the container is reached and cannot be increased. |
|
inline |
Move one element to the end of the buffer.
This invalidates all existing iterators.
std::length_error | is thrown if the maximum capacity of the container is reached and cannot be increased. |
|
inlinenoexcept |
Return a reverse iterator to the first element of the reversed vector (which is the last element of the actual vector).
The iterator cannot be dereferenced if the vector is empty.
References gul14::SmallVector< ElementT, in_capacity >::end().
|
inlinenoexcept |
Return a reverse iterator pointing past the last element of the reversed vector.
The iterator cannot be dereferenced if the vector is empty.
References gul14::SmallVector< ElementT, in_capacity >::begin().
|
inline |
Increase the capacity of the vector to the specified size.
This call can only enlarge the container. If new_capacity < capacity(), the call does nothing.
new_capacity | The new capacity of the vector |
References gul14::SmallVector< ElementT, in_capacity >::data().
Referenced by gul14::SmallVector< ElementT, in_capacity >::assign(), gul14::SmallVector< ElementT, in_capacity >::operator=(), gul14::SmallVector< ElementT, in_capacity >::resize(), and gul14::SmallVector< ElementT, in_capacity >::SmallVector().
|
inline |
Change the number of elements in the container.
If the number of elements is decreased, superfluous elements are removed from the end of the container and the capacity is not changed. If the number of elements is increased, default-constructed elements are added at the end of the container and the capacity can grow.
num_elements | The desired number of elements after resizing |
References gul14::SmallVector< ElementT, in_capacity >::data(), and gul14::SmallVector< ElementT, in_capacity >::reserve().
|
inline |
Change the number of elements in the container.
If the number of elements is decreased, superfluous elements are removed from the end of the container and the capacity is not changed. If the number of elements is increased, copies of the specified element are added at the end of the container and the capacity can grow.
num_elements | The desired number of elements after resizing |
element | The element to be copied into the new cells when enlarging |
References gul14::SmallVector< ElementT, in_capacity >::data(), and gul14::SmallVector< ElementT, in_capacity >::reserve().
|
inline |
Reduce the capacity as far as possible while retaining all stored elements.
This might free up some space on the heap, and it invalidates existing iterators.
References gul14::SmallVector< ElementT, in_capacity >::data(), and gul14::SmallVector< ElementT, in_capacity >::inner_capacity().
|
inline |
Exchange the contents of this SmallVector with those of another one.
If either this or the other vector have internally stored elements (capacity() <= inner_capacity()), this function falls back to element-wise swapping. Otherwise, the heap-allocated buffers are swapped directly.
Referenced by gul14::swap().
|
friend |
Inequality operator: Return true if both vectors have a different size() or at least one different element.
lhs | First vector. |
rhs | Second vector. |
|
friend |
Equality operator: Return true if both vectors have the same size() and the same elements.
lhs | First vector. |
rhs | Second vector. |