keen/col/experimental/list

Source
list[t] record (has private fields)

Immutable list type.

This type is designed so concatenation (~ and ~~) will be efficient. It also is efficient to split from an iterator.

It does not support efficient access by an index, so iterators should be used instead.

list-new[t] t list(a t[])
subscript[t] t(a t list, index nat64)
subscript[t] t list(a t list, indices nat64 range)
to[t] t list(a t[])
Convert an array to a list. This is O(1).
to[t] t[](a t list)
Convert a list to an array. This is O(a size). This is O(1) if the list was converted from an array, meaning a round trip is free.
==[t] bool(a t list, b t list) t equal
<=>[t] comparison(a t list, b t list) t compare
is-empty[t] bool(a t list)
true if a.size == 0. This is O(1).
~~[t] t list(a t list, b t list)
Concatenate two lists. This is O(log n), where n is the size of the smaller list.
~[t] t list(a t, b t list)
Prepend an element to a list. This is amortized O(1), with worst case O(a.size log).
~[t] t list(a t list, b t)
Append an element to a list. This is amortized O(1), with worst case O(a.size log).
size[t] nat64(a t list)
Number of elements in the list. This is O(n) where 'n' is the result.
some[t] bool(a t list, f bool mut(t))
list-mut-iterator[t] record (has private fields)
copy[t] t list-mut-iterator(a t list-mut-iterator)
take-prev[t] t(a t list-mut-iterator)
take-next[t] t(a t list-mut-iterator)
begin[t] t list-mut-iterator(a t list)
end[t] t list-mut-iterator(a t list)
slice[t] t list(a t list-mut-iterator, b t list-mut-iterator)
index[t] nat64(a t list-mut-iterator)
-[t] nat64(a t list-mut-iterator, b t list-mut-iterator)
skip-next-n[t] void(a t list-mut-iterator, n nat64)