Implementation of a dynamic array with small array optimization.The SmallArray class template is a hybrid data structure between a static array and a dynamic array. It provides static, in-place memory for up to N elements of type T, but can grow beyond this size by allocating dynamic memory via its allocator of type A.
More...
#include <SmallArray.h>
Inherits SmallArrayData< T, N >, and A.
|
using | ElementType = T |
| Type of the array elements.
|
|
using | Pointer = T * |
| Pointer to a non-constant array element.
|
|
using | ConstPointer = const T * |
| Pointer to a constant array element.
|
|
using | Reference = T & |
| Reference to a non-constant array element.
|
|
using | ConstReference = const T & |
| Reference to a constant array element.
|
|
using | Iterator = T * |
| Iterator over non-constant elements.
|
|
using | ConstIterator = const T * |
| Iterator over constant elements.
|
|
|
|
T * | begin_ |
| Pointer to the beginning of the currently used storage.
|
|
T * | end_ |
| Pointer to the end of the currently used storage.
|
|
T * | final_ |
| Pointer to the very end of the currently used storage.
|
|
template<typename T, size_t N, typename A = std::allocator<T>>
class blaze::SmallArray< T, N, A >
Implementation of a dynamic array with small array optimization.
The SmallArray class template is a hybrid data structure between a static array and a dynamic array. It provides static, in-place memory for up to N elements of type T, but can grow beyond this size by allocating dynamic memory via its allocator of type A.
◆ SmallArray() [1/8]
template<typename T , size_t N, typename A >
The (default) constructor for SmallArray.
- Parameters
-
alloc | Allocator for all memory allocations of this container. |
◆ SmallArray() [2/8]
template<typename T , size_t N, typename A >
Constructor for an array of size n. No element initialization is performed!
- Parameters
-
n | The initial size of the array. |
alloc | Allocator for all memory allocations of this container. |
◆ SmallArray() [3/8]
template<typename T , size_t N, typename A >
Constructor for an array of size n.
- Parameters
-
n | The initial size of the array. |
init | The initial value of the array elements. |
alloc | Allocator for all memory allocations of this container. |
All array elements are initialized with the specified value.
◆ SmallArray() [4/8]
template<typename T , size_t N, typename A >
template<typename InputIt >
Constructor for a range of elements.
- Parameters
-
first | Iterator to the be first element of the input range. |
last | Iterator to the element one past the last element of the input range. |
alloc | Allocator for all memory allocations of this container. |
◆ SmallArray() [5/8]
template<typename T , size_t N, typename A >
template<typename U >
List initialization of all array elements.
- Parameters
-
list | The initializer list. |
alloc | Allocator for all memory allocations of this container. |
This constructor provides the option to explicitly initialize the elements of the small array within a constructor call:
The array is sized according to the size of the initializer list and all its elements are copy initialized by the elements of the given initializer list.
◆ SmallArray() [6/8]
template<typename T , size_t N, typename A >
The copy constructor for SmallArray.
- Parameters
-
sa | The small array to be copied. |
◆ SmallArray() [7/8]
template<typename T , size_t N, typename A >
The move constructor for SmallArray.
- Parameters
-
sa | The small array to be moved into this instance. |
◆ SmallArray() [8/8]
template<typename T , size_t N, typename A >
Auxiliary constructor for SmallArray.
- Parameters
-
n | The initial size of the array. |
alloc | Allocator for all memory allocations of this container. |
◆ at() [1/2]
template<typename T , size_t N, typename A >
Checked access to the array elements.
- Parameters
-
index | Access index. The index has to be in the range . |
- Returns
- Reference to the accessed value.
- Exceptions
-
std::out_of_range | Invalid small array access index. |
In contrast to the subscript operator this function always performs a check of the given access index.
◆ at() [2/2]
template<typename T , size_t N, typename A >
Checked access to the array elements.
- Parameters
-
index | Access index. The index has to be in the range . |
- Returns
- Reference to the accessed value.
- Exceptions
-
std::out_of_range | Invalid small array access index. |
In contrast to the subscript operator this function always performs a check of the given access index.
◆ begin() [1/2]
template<typename T , size_t N, typename A >
Returns an iterator to the first element of the small array.
- Returns
- Iterator to the first element of the small array.
◆ begin() [2/2]
template<typename T , size_t N, typename A >
Returns an iterator to the first element of the small array.
- Returns
- Iterator to the first element of the small array.
◆ capacity()
template<typename T , size_t N, typename A >
Returns the maximum capacity of the small array.
- Returns
- The capacity of the small array.
◆ cbegin()
template<typename T , size_t N, typename A >
Returns an iterator to the first element of the small array.
- Returns
- Iterator to the first element of the small array.
◆ cend()
template<typename T , size_t N, typename A >
Returns an iterator just past the last element of the small array.
- Returns
- Iterator just past the last element of the small array.
◆ clear()
template<typename T , size_t N, typename A >
Clearing the array.
- Returns
- void
After the clear() function, the size of the array is 0.
◆ data() [1/2]
template<typename T , size_t N, typename A >
Low-level data access to the array elements.
- Returns
- Pointer to the internal element storage.
This function returns a pointer to the internal storage of the small array.
◆ data() [2/2]
template<typename T , size_t N, typename A >
Low-level data access to the array elements.
- Returns
- Pointer to the internal element storage.
This function returns a pointer to the internal storage of the small array.
◆ empty()
template<typename T , size_t N, typename A >
Returns whether the array is empty.
- Returns
- true in case the array is empty, false if not.
◆ end() [1/2]
template<typename T , size_t N, typename A >
Returns an iterator just past the last element of the small array.
- Returns
- Iterator just past the last element of the small array.
◆ end() [2/2]
template<typename T , size_t N, typename A >
Returns an iterator just past the last element of the small array.
- Returns
- Iterator just past the last element of the small array.
◆ erase() [1/2]
template<typename T , size_t N, typename A >
Erasing an element from the small array.
- Parameters
-
pos | Iterator to the element to be erased. |
- Returns
- Iterator to the element after the erased element.
This function erases an element from the small array.
◆ erase() [2/2]
template<typename T , size_t N, typename A >
Erasing a range of elements from the small array.
- Parameters
-
first | Iterator to first element to be erased. |
last | Iterator just past the last element to be erased. |
- Returns
- Iterator to the element after the erased element.
This function erases a range of elements from the small array.
◆ insert() [1/2]
template<typename T , size_t N, typename A >
Inserting an element at the specified position into the small array.
- Parameters
-
pos | The position of the new element. |
value | The value of the element to be inserted. |
- Returns
- Reference to the inserted value.
◆ insert() [2/2]
template<typename T , size_t N, typename A >
Inserting an element at the specified position into the small array.
- Parameters
-
pos | The position of the new element. |
value | The value of the element to be inserted. |
- Returns
- Reference to the inserted value.
◆ isDynamic()
template<typename T , size_t N, typename A >
Returns whether the small array uses its dynamic storage.
- Returns
- true in case the dynamic storage is in use, false if not.
◆ operator=() [1/3]
template<typename T , size_t N, typename A >
Copy assignment operator for SmallArray.
- Parameters
-
- Returns
- Reference to the assigned array.
The array is resized according to the given small array and initialized as a copy of this array.
◆ operator=() [2/3]
template<typename T , size_t N, typename A >
Move assignment operator for SmallArray.
- Parameters
-
rhs | The array to be moved into this instance. |
- Returns
- Reference to the assigned array.
◆ operator=() [3/3]
template<typename T, size_t N, typename A = std::allocator<T>>
template<typename U >
List assignment to all array elements.
- Parameters
-
list | The initializer list. |
This assignment operator offers the option to directly assign to all elements of the small array by means of an initializer list:
The array is resized according to the size of the initializer list and all its elements are assigned the values from the given initializer list.
◆ operator[]() [1/2]
template<typename T , size_t N, typename A >
Subscript operator for the direct access to the array elements.
- Parameters
-
index | Access index. The index has to be in the range . |
- Returns
- Reference to the accessed value.
This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access index.
◆ operator[]() [2/2]
template<typename T , size_t N, typename A >
Subscript operator for the direct access to the array elements.
- Parameters
-
index | Access index. The index has to be in the range . |
- Returns
- Reference-to-const to the accessed value.
This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access index.
◆ pushBack() [1/2]
template<typename T , size_t N, typename A >
Adding an element to the end of the small array.
- Parameters
-
value | The element to be added to the end of the small array. |
- Returns
- void
◆ pushBack() [2/2]
template<typename T , size_t N, typename A >
Adding an element to the end of the small array.
- Parameters
-
value | The element to be added to the end of the small array. |
- Returns
- void
◆ reserve()
template<typename T , size_t N, typename A >
Setting the minimum capacity of the array.
- Parameters
-
n | The new minimum capacity of the array. |
- Returns
- void
This function increases the capacity of the array to at least n elements. The current values of the array elements are preserved.
◆ resize() [1/2]
template<typename T , size_t N, typename A >
Changing the size of the array.
- Parameters
-
n | The new size of the array. |
- Returns
- void
This function resizes the array using the given size to n. During this operation, new dynamic memory may be allocated in case the capacity of the array is too small. New array elements are not initialized!
◆ resize() [2/2]
template<typename T , size_t N, typename A >
Changing the size of the array.
- Parameters
-
n | The new size of the array. |
value | The initial value of new array elements. |
- Returns
- void
This function resizes the array using the given size to n. During this operation, new dynamic memory may be allocated in case the capacity of the array is too small. New array elements are initialized to value!
◆ shrinkToFit()
template<typename T , size_t N, typename A >
Requesting the removal of unused capacity.
- Returns
- void
This function minimizes the capacity of the array by removing unused capacity. Please note that in case a reallocation occurs, all iterators (including end() iterators), all pointers and references to elements of this array are invalidated.
◆ size()
template<typename T , size_t N, typename A >
Returns the current size/dimension of the small array.
- Returns
- The current size of the small array.
◆ swap()
template<typename T , size_t N, typename A >
Swapping the contents of two small arrays.
- Parameters
-
sa | The small array to be swapped. |
- Returns
- void
This function swaps the contents of two small arrays. Please note that this function is only guaranteed to not throw an exception if the move constructor of the underlying data type T is guaranteed to be noexcept.
The documentation for this class was generated from the following file: