Class Subspace :: sus :: collections :: Array
A collection of objects of type T
, with a fixed size N
.
An Array can not be larger than isize::MAX
, as
subtracting a pointer at a greater distance results in Undefined Behaviour.
Static Methods
Default constructor of Array
which default-constructs each object T
in
the array.
This satisifies Default
for the
Array<T, N>
if Default
is satisifed for
T
.
Constructs an Array
with N
elements from the N
arguments given to
the constructor.
Constructs an Array
with N
elements, where each element is constructed
from the given closure.
std::convertible_to<U, T>
sus::mem::Copy<T>
Constructs an Array
with N
elements from a single argument, repeatedly
using it to construct each element. The given argument must be Copy
in
order to do this.
To construct an Array from a single value that is Clone
but not Copy
,
use with_initializer([&x]() -> T { return sus::clone(x); })
;
Methods
Returns a mutable pointer to the first element in the array.
Returns a const pointer to the first element in the array.
Returns a const reference to the element at index i
.
Returns a mutable reference to the element at index i
.
Returns a const reference to the element at index i
.
Safety
The index i
must be inside the bounds of the array or Undefined
Behaviour results.
Returns a mutable reference to the element at index i
.
Safety
The index i
must be inside the bounds of the array or Undefined
Behaviour results.
sus::mem::Move<T>
Converts the array into an iterator that consumes the array and returns each element in the same order they appear in the array.
Returns an iterator over all the elements in the array, visited in the same order they appear in the array. The iterator gives const access to each element.
Returns an iterator over all the elements in the array, visited in the same order they appear in the array. The iterator gives mutable access to each element.
Returns the number of elements in the array.
Consumes the array, and returns a new array, mapping each element of the array to a new type with the given function.
To just walk each element and map them, consider using iter()
and
Iterator::map
. This does not require consuming the array.
Operators
sus::cmp::Eq<T, U>
sus::cmp::Eq<T>
Satisfies the Eq<Array<T, N>, Array<U, N>>
concept.