Module tanya.range.array

tanya.range.array implements range primitives for built-in arrays.

This module is a submodule of tanya.range.

After importing of tanya/range/array.d built-in arrays can act as bidirectional ranges. For that to work the module defines a set of functions that accept a built-in array of any type as their first argument, so thanks to UFCS (Uniform Function Call Syntax) they can be called as if they were array member functions. For example the arrays the .length-property, but no .empty property. So here can be find the empty function. Since empty(array) and array.empty are equal for the arrays, arrays get a faked property empty.

The functions in this module don't change array elements or its underlying storage, but some functions alter the slice. Each array maintains a pointer to its data and the length and there can be several pointers which point to the same data. Array pointer can be advanced and the length can be reduced without changing the underlying storage. So slices offer the possibility to have multiple views into the same array, point to different positions inside it.

Strings (char[], (D_INLINECODE wchar[]) and (D_INLINECODE dchar[])) are treated as any other normal array, they aren't auto-decoded.

Functions

NameDescription
back(array) Returns the last element of the array.
empty(array) Tests whether array is empty.
front(array) Returns the first element of the array.
popBack(array) popFront and popBack advance the array and remove one element from its back, respectively.
popFront(array) popFront and popBack advance the array and remove one element from its back, respectively.
save(array) Returns a copy of the slice array.