Luna::Array
Represents one array of fixed or dynamic size.
template <typename _Ty, usize _Size>
class Luna::Array
Array is one container that contains fixed number of elements. The size of one array can be set in compile time by specifying _Size
of the array, or can be set when creating the array by setting _Size
to DYNAMIC_ARRAY_SIZE. Unlike Vector, the size of one array cannot be changed after the array is created. If the size of the array is determined in compile time, the memory for elements will be allocated directly in the array object; if the size of the array is determined in run time, the memory for elements will be allocated dynamically on heap.
Member functions
-
constexpr reference at(usize pos)
Gets a refernece of the element at the specified index.
-
constexpr const_reference at(usize pos) const
Gets a const refernece of the element at the specified index.
-
constexpr reference operator[](usize pos)
Gets a refernece of the element at the specified index.
-
constexpr const_reference operator[](usize pos) const
Gets a constant refernece of the element at the specified index.
-
Gets a reference to the first (index 0) element in the array.
-
constexpr const_reference front() const
Gets a constant reference to the first (index 0) element in the array.
-
Gets a reference to the last (index
size()
- 1) element in the array. -
constexpr const_reference back() const
Gets a reference to the last (index
size()
- 1) element in the array. -
Gets one pointer to the array data memory.
-
constexpr const _Ty * data() const
Gets one constant pointer to the array data memory.
-
Gets one iterator to the first element of the array.
-
constexpr const_iterator begin() const
Gets one constant iterator to the first element of the array.
-
constexpr const_iterator cbegin() const
Gets one constant iterator to the first element of the array.
-
Gets one iterator to the one past last element of the array.
-
constexpr const_iterator end() const
Gets one constant iterator to the one past last element of the array.
-
constexpr const_iterator cend() const
Gets one constant iterator to the one past last element of the array.
-
constexpr reverse_iterator rbegin()
Gets one reverse iterator to the last element of the array.
-
constexpr const_reverse_iterator rbegin() const
Gets one constant reverse iterator to the last element of the array.
-
constexpr const_reverse_iterator crbegin() const
Gets one constant reverse iterator to the last element of the array.
-
constexpr reverse_iterator rend()
Gets one reverse iterator to the one-before-first element of the array.
-
constexpr const_reverse_iterator rend() const
Gets one constant reverse iterator to the one-before-first element of the array.
-
constexpr const_reverse_iterator crend() const
Gets one constant reverse iterator to the one-before-first element of the array.
-
Checks whether this array is empty, that is, the size of this array is
0
. -
Gets the size of the array.
-
constexpr void fill(const _Ty &value)
Assigns every element in the array with the specified value.
-
constexpr void swap(Array &rhs)
Swaps content of this array with another array of the same element type and size.