Data.Array
No module comment.
A fixed-length array: its length is set when it is made and never changes,
and its elements can be assigned. Its one field cannot be assigned, so at run
time an Array is the primitive array itself, with its length in the
header. That header is the only length there is, so the test get and set
make for the program's error message is also the one that keeps the access
inside the storage, and in a loop bounded by len(xs) the compiler proves
both away.
An array literal the program uses as an Array is built as this constructor
applied to the primitive array, by name; renaming it means changing how the
compiler lowers a literal in the same commit.
An Array of storage the caller made and hands over, for the rest of the
library.
The storage an Array is, for the rest of the library to hand to a bulk
primitive: ofStorage the other way.
Returns a read-only view of xs, without copying it. The view cannot write
to xs, but whoever holds xs still can, and the view shows each write as
it happens.
Element i is f(i), computed in order from 0.
f of each element of xs, in order. xs is anything with a length that
can be iterated, so a Vec maps straight to an Array.
The loop counts to the length rather than running to the end of the
iteration, so every slot of the result is written: an iterator that ends
early -- a Vec that f pops from -- panics instead of leaving a hole.
How many elements are kept is known only at the end, and keep is called
once per element, in order. So the kept ones go into scratch storage as long
as xs, which is copied once into an array of their number unless they are
all of it.
Returns the result of calling step on the accumulator and each element in
turn. Iter.fold takes the same arguments and works on anything iterable.
Copy count elements of source, from index from on, over those of
target from index at on. The two may be one array, and the runs may
overlap: every element arrives as it was before the copy began. Panics
unless both runs are inside their arrays.
Set the count elements of target from index at on to value.
Panics unless they are all elements of target.
A copy, not a view: writing to one leaves the other as it was.
A stable sort, answering a new Array; Turkey.Array says how.
Sorted by key, stably, calling key once per element. Each element is
paired with its key and the pairs sorted, which costs two arrays of pairs
where comparing key(a) with key(b) would cost none, and is worth it:
that would call key twice per comparison, and a key is often a lookup or
a system call.
Ord answers in Bool, so a three-way comparison costs two questions.
Ordering is the shape a sort wants, and this is the adapter.
Every f(x) is made first, so the result is allocated once, at their total
length.
Equal when they have the same length and equal elements at each index.
Compares element by element from the front: the first index where the two differ decides, and an array that is a proper prefix of the other is less.
Its elements, as the array literal that builds it.
What its Debug prints: a container's text shows its elements' Debug,
so that a string in it is quoted.