The Array class provides functionality similar to std::vector, except that it does not construct or destruct elements, and does not allow insertions or append. This is for performance reasons when initialization is not required. However, this makes it unsuitable for anything other than primitive datatypes or other structures movemable with a simple memcpy().
More...
#include <Array.hpp>
|
|
using | iterator = T * |
| |
|
using | const_iterator = T const * |
| |
|
|
| Array () |
| | Default constructor, creating an empty array. This is only useful for reserve stack space in order to re-assign.
|
| |
| | Array (size_t const size) |
| | Create a new mutable array. More...
|
| |
| | Array (size_t const size, T const value) |
| | Create a new mutable array with a default value for each element. More...
|
| |
| | Array (Array &&lhs) noexcept |
| | Move constructor. More...
|
| |
| | Array (Array const &rhs)=delete |
| | Deleted copy-assignment operator. More...
|
| |
| Array & | operator= (Array const &rhs)=delete |
| | Deleted assignment operator. More...
|
| |
| Array & | operator= (Array &&lhs) |
| | Assignment operator (move). More...
|
| |
| void | set (T const val) noexcept |
| | Set all entries in the array to the given value. More...
|
| |
| T & | operator[] (size_t const index) noexcept |
| | Get the element at the given index. More...
|
| |
| T const & | operator[] (size_t const index) const noexcept |
| | Get the element at the given index. More...
|
| |
| T * | data () noexcept |
| | Get the underlying memory. More...
|
| |
| T const * | data () const noexcept |
| | Get the underlying memory. More...
|
| |
| size_t | size () const noexcept |
| | Get the size of the underlying memory allocation. More...
|
| |
| const_iterator | begin () const noexcept |
| | Get the beginning iterator. More...
|
| |
| const_iterator | end () const noexcept |
| | Get the end iterator. More...
|
| |
| iterator | begin () noexcept |
| | Get the beginning iterator (mutable). More...
|
| |
| iterator | end () noexcept |
| | Get the end iterator (mutable). More...
|
| |
| T const & | front () const noexcept |
| | Get the front of the array. More...
|
| |
| T & | front () noexcept |
| | Get the front of the array. More...
|
| |
| T const & | back () const noexcept |
| | Get the back of the array. More...
|
| |
| T & | back () noexcept |
| | Get the back of the array. More...
|
| |
| void | shrink (size_t smallerSize) |
| | Shrink the size of the array. This does not gaurantee the memory allocation will be decreased, but only that the local size of the array will shrink. Calling this method with a smallerSize greater than the size of the array will have no effect. More...
|
| |
| std::unique_ptr< T[]> | steal () noexcept |
| | Pull out the heap memory from this Array, leaving it empty. More...
|
| |
|
void | clear () |
| | Free the memory associated with this array.
|
| |
template<typename T>
class sl::Array< T >
The Array class provides functionality similar to std::vector, except that it does not construct or destruct elements, and does not allow insertions or append. This is for performance reasons when initialization is not required. However, this makes it unsuitable for anything other than primitive datatypes or other structures movemable with a simple memcpy().
- Template Parameters
-
◆ Array() [1/4]
Create a new mutable array.
- Parameters
-
| size | The size of the array. |
◆ Array() [2/4]
Create a new mutable array with a default value for each element.
- Parameters
-
| size | The size of the array. |
◆ Array() [3/4]
Move constructor.
- Parameters
-
◆ Array() [4/4]
Deleted copy-assignment operator.
- Parameters
-
◆ back() [1/2]
Get the back of the array.
- Returns
- The last element.
◆ back() [2/2]
Get the back of the array.
- Returns
- The last element.
◆ begin() [1/2]
template<typename T>
| const_iterator sl::Array< T >::begin |
( |
| ) |
const |
|
inlinenoexcept |
Get the beginning iterator.
- Returns
- The iterator/pointer.
◆ begin() [2/2]
Get the beginning iterator (mutable).
- Returns
- The iterator/pointer.
◆ data() [1/2]
Get the underlying memory.
- Returns
- The underlying memory.
◆ data() [2/2]
Get the underlying memory.
- Returns
- The underlying memory.
◆ end() [1/2]
Get the end iterator.
- Returns
- The iterator/pointer.
◆ end() [2/2]
Get the end iterator (mutable).
- Returns
- The iterator/pointer.
◆ front() [1/2]
Get the front of the array.
- Returns
- The first element.
◆ front() [2/2]
Get the front of the array.
- Returns
- The first element.
◆ operator=() [1/2]
Deleted assignment operator.
- Parameters
-
- Returns
- This array.
◆ operator=() [2/2]
Assignment operator (move).
- Parameters
-
| lhs | The array to assign (and destroy) to this one. |
- Returns
- This array.
◆ operator[]() [1/2]
template<typename T>
| T& sl::Array< T >::operator[] |
( |
size_t const |
index | ) |
|
|
inlinenoexcept |
Get the element at the given index.
- Parameters
-
| index | The index of the element. |
- Returns
- A reference to the element.
◆ operator[]() [2/2]
template<typename T>
| T const& sl::Array< T >::operator[] |
( |
size_t const |
index | ) |
const |
|
inlinenoexcept |
Get the element at the given index.
- Parameters
-
| index | The index of the element. |
- Returns
- A reference to the element.
◆ set()
Set all entries in the array to the given value.
- Parameters
-
◆ shrink()
template<typename T>
| void sl::Array< T >::shrink |
( |
size_t |
smallerSize | ) |
|
|
inline |
Shrink the size of the array. This does not gaurantee the memory allocation will be decreased, but only that the local size of the array will shrink. Calling this method with a smallerSize greater than the size of the array will have no effect.
- Parameters
-
| smallerSize | The size to shrink the array to. |
◆ size()
Get the size of the underlying memory allocation.
- Returns
- The size of the memory allocation.
◆ steal()
template<typename T>
| std::unique_ptr<T[]> sl::Array< T >::steal |
( |
| ) |
|
|
inlinenoexcept |
Pull out the heap memory from this Array, leaving it empty.
- Returns
- The unique pointer to the heap memory.
The documentation for this class was generated from the following file: