Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.array.primitives

Range primitives for arrays with multi-dimensional like API support.

Note: UTF strings behaves like common arrays in Mir. std.uni.byCodePoint can be used to creat a range of chararacters.

See Also:
Authors:
Ilya Yaroshenko
bool empty(size_t dim = 0, T)(in T[] ar)
if (!dim);
Examples:
assert((int[]).init.empty);
assert(![1].empty!0); // Slice-like API
ref auto front(size_t dim = 0, T)(T[] ar)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
assert(*&[3, 4].front == 3); // access be ref
assert([3, 4].front!0 == 3); // Slice-like API
ref auto back(size_t dim = 0, T)(T[] ar)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
assert(*&[3, 4].back == 4); // access be ref
assert([3, 4].back!0 == 4); // Slice-like API
void popFront(size_t dim = 0, T)(ref T[] ar)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
auto ar = [3, 4];
ar.popFront;
assert(ar == [4]);
ar.popFront!0;  // Slice-like API
assert(ar == []);
void popBack(size_t dim = 0, T)(ref T[] ar)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
auto ar = [3, 4];
ar.popBack;
assert(ar == [3]);
ar.popBack!0;  // Slice-like API
assert(ar == []);
size_t popFrontN(size_t dim = 0, T)(ref T[] ar, size_t n)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
auto ar = [3, 4];
ar.popFrontN(1);
assert(ar == [4]);
ar.popFrontN!0(10);  // Slice-like API
assert(ar == []);
size_t popBackN(size_t dim = 0, T)(ref T[] ar, size_t n)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
auto ar = [3, 4];
ar.popBackN(1);
assert(ar == [3]);
ar.popBackN!0(10);  // Slice-like API
assert(ar == []);
void popFrontExactly(size_t dim = 0, T)(ref T[] ar, size_t n)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
auto ar = [3, 4, 5];
ar.popFrontExactly(2);
assert(ar == [5]);
ar.popFrontExactly!0(1);  // Slice-like API
assert(ar == []);
void popBackExactly(size_t dim = 0, T)(ref T[] ar, size_t n)
if (!dim && !is(Unqual!T[] == void[]));
Examples:
auto ar = [3, 4, 5];
ar.popBackExactly(2);
assert(ar == [3]);
ar.popBackExactly!0(1);  // Slice-like API
assert(ar == []);
size_t length(size_t d : 0, T)(T[] array)
if (d == 0);
Examples:
assert([1, 2].length!0 == 2);
alias elementsCount = length(ulong d : 0, T)(T[] array) if (d == 0);