Struct Array

One dimensional array.

struct Array(T) ;

Constructors

NameDescription
this (init, allocator) Creates a new Array with the elements from a static array.
this (init, allocator) Creates a new Array with the elements from an input range.
this (init, allocator) Initializes this array from another one.
this (len, init, allocator) Creates a new Array.

Properties

NameTypeDescription
back[get] inout(T)
capacity[get] size_t
empty[get] bool
front[get] inout(T)
length[get] size_t
length[set] size_tExpands/shrinks the array.

Methods

NameDescription
clear () Removes all elements.
get () Returns an array used internally by the array to store its owned elements. The length of the returned array may differ from the size of the allocated memory for the array: the array contains only initialized elements, but not the reserved memory.
insertAfter (r, el) Inserts el before or after r.
insertBack (el) Inserts the el into the array.
insertBefore (r, el) Inserts el before or after r.
opAssign (that) Assigns another array.
opAssign (that) Assigns a range to the array.
opAssign (that) Assigns a static array.
opDollar ()
opEquals (that) Comparison for equality.
opEquals (that) Comparison for equality.
opIndex (pos)
opIndex ()
opIndexAssign (value, pos) Assigns a value to the element with the index pos.
opIndexAssign (value) Assigns a range or a static array.
opSlice (i, j)
opSliceAssign (value, i, j) Slicing assignment.
remove (r) Remove all elements beloning to r.
removeBack () Removes the value at the back of the array.
removeBack (howMany) Removes howMany elements from the array.
reserve (size) Reserves space for size elements.
shrink (size) Requests the array to reduce its capacity to fit the size.

Aliases

NameDescription
ConstRange The range types for Array.
insert Inserts the el into the array.
Range The range types for Array.

Parameters

NameDescription
T Content type.

Example

auto v = Array!int([5, 15, 8]);

assert(v.front == 5);
assert(v[1] == 15);
assert(v.back == 8);

auto r = v[];
r[0] = 7;
assert(r.front == 7);
assert(r.front == v.front);