![]() |
Gamedev Framework (gf)
0.16.0
A C++14 framework for 2D games
|
A constant reference to an array and its size. More...
#include <gf/ArrayRef.h>
Public Member Functions | |
constexpr | ArrayRef () |
Default constructor. More... | |
constexpr | ArrayRef (std::nullptr_t) |
Null constructor. More... | |
constexpr | ArrayRef (const T *data, std::size_t size) |
Constructor from a pointer and a size. More... | |
ArrayRef (const std::vector< T > &values) | |
Constructor from a std::vector More... | |
template<std::size_t N> | |
ArrayRef (const std::array< T, N > &values) | |
Constructor from a std::array More... | |
template<std::size_t N> | |
constexpr | ArrayRef (const T(&data)[N]) |
Constructor from a static array. More... | |
constexpr const T * | getData () const noexcept |
Get a pointer to the elements. More... | |
constexpr std::size_t | getSize () const noexcept |
Get the number of elements. More... | |
constexpr bool | isEmpty () const noexcept |
Check if the array is empty. More... | |
constexpr ArrayRef< T > | sub (std::size_t index) |
Create an array starting at a specified index. More... | |
constexpr const T * | begin () const noexcept |
Get an iterator to the first element. More... | |
constexpr const T * | end () const noexcept |
Get an iterator past the last element. More... | |
constexpr const T & | operator[] (std::size_t index) const |
Get an element at a given index. More... | |
A constant reference to an array and its size.
This class stores a pointer to some data and its size. It can be built from various inputs: std::vector
, static array, pointer and size.
|
inline |
Default constructor.
Data is nullptr
and size is 0.
|
inline |
Null constructor.
Data is nullptr
and size is 0.
|
inline |
Constructor from a pointer and a size.
data | A pointer to the elements in the array |
size | The number of elements in the array |
|
inline |
Constructor from a std::vector
values | The vector of elements |
|
inline |
Constructor from a std::array
values | The array of elements |
|
inline |
Constructor from a static array.
The size is computed at compile-time.
data | The static array |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Get a pointer to the elements.
|
inlinenoexcept |
Get the number of elements.
|
inlinenoexcept |
Check if the array is empty.
|
inline |
Get an element at a given index.
No verification is done on the index.
index | The index of the element |
|
inline |
Create an array starting at a specified index.
index | The starting index of the new array |