Array<T>

Array adapters materialize fresh arrays; methods marked mutating change the receiver explicitly.

Methods

fn len() -> intquery#

Returns the number of array elements.

fn iter() -> Iterator<T>adapter#

Creates a fresh array cursor, or returns the same iterator cursor without rewinding it.

fn get(index: int) -> Tquery#

Returns the indexed element or reports an out-of-bounds error.

fn slice(start: int, end: int) -> [T]query#

Returns a fresh clamped half-open slice.

fn contains(value: T) -> boolquery#

Tests equality with value.eql.

fn is_empty() -> boolquery#

Returns whether the array has no elements.

fn is_not_empty() -> boolquery#

Returns whether the array contains at least one element.

fn map<U>(callback: fn(T) -> U) -> [U]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn map_indexed<U>(callback: fn(int, T) -> U) -> [U]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn filter(predicate: fn(T) -> bool) -> [T]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn filter_not(predicate: fn(T) -> bool) -> [T]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn filter_indexed(predicate: fn(int, T) -> bool) -> [T]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn filter_map<U>(callback: fn(T) -> Optional<U>) -> [U]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn map_not_none<U>(callback: fn(T) -> Optional<U>) -> [U]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn flat_map<U>(callback: fn(T) -> [U] | Iterator<U>) -> [U]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn on_each(callback: fn(T) -> void) -> [T]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn running_fold<U>(initial: U, callback: fn(U, T) -> U) -> [U]adapter#

Includes the initial accumulator, then one value for every consumed item.

fn running_reduce(callback: fn(T, T) -> T) -> [T]adapter#

Yields each intermediate reduction and is empty for empty input.

fn take_last(count: int) -> [T]adapter#

Uses bounded buffering; negative counts clamp to zero.

fn drop_last(count: int) -> [T]adapter#

Uses bounded buffering; negative counts clamp to zero.

fn chunked(size: int) -> [[T]]adapter#

Produces snapshot arrays and includes a final short chunk; size must be positive.

fn windowed(size: int, step: int = 1, partial: bool = false) -> [[T]]adapter#

Produces non-aliasing sliding-window snapshots; size and step must be positive.

fn zip_with_next() -> [(T, T)]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn interleave(other: [T]) -> [T]adapter#

Alternates elements until both sources are exhausted.

fn enumerate() -> [(int, T)]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn zip<U>(other: [U]) -> [(T, U)]adapter#

Array receivers materialize a fresh result; iterator receivers create a lazy, single-pass adapter.

fn plus(other: [T]) -> [T]query#

Returns a fresh concatenated array.

fn minus(value: T) -> [T]query#

Returns a fresh array with the first equal occurrence removed.

fn minus_all(values: [T]) -> [T]query#

Returns a fresh array without elements equal to any supplied value.

fn sort() -> [T]query#

Returns a fresh stable ascending array.

fn sort_desc() -> [T]query#

Returns a fresh stable descending array.

fn index_of(value: T) -> intquery#

Returns the first index equal to value, or -1. Use contains for a membership test, or index_first for a predicate search returning Optional<int>.

fn distinct() -> [T]adapter#

Retains first occurrences in input order; iterator state may grow without bound.

fn distinct_by<K>(selector: fn(T) -> K) -> [T]adapter#

Retains the first item for each selector key in input order.

fn first_or_none() -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn last_or_none() -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn first_where(predicate: fn(T) -> bool) -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn last_where(predicate: fn(T) -> bool) -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn single_or_none() -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn element_at_or_none(index: int) -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn index_first(predicate: fn(T) -> bool) -> Optional<int>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn index_last(predicate: fn(T) -> bool) -> Optional<int>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn none(predicate: fn(T) -> bool) -> boolterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn contains_all(values: [T]) -> boolterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn partition(predicate: fn(T) -> bool) -> ([T], [T])terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn associate<K,V>(callback: fn(T) -> (K,V)) -> {K: V}terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn associate_by<K>(selector: fn(T) -> K) -> {K: T}terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn associate_with<V>(selector: fn(T) -> V) -> {T: V}terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn group_by<K>(selector: fn(T) -> K) -> {K: [T]}terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn group_map<K,V>(key: fn(T) -> K, value: fn(T) -> V) -> {K: [V]}terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn group_count<K>(selector: fn(T) -> K) -> {K: int}terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn sorted_by<K>(selector: fn(T) -> K) -> [T]terminal#

Stable; evaluates the selector exactly once per item.

fn sorted_by_desc<K>(selector: fn(T) -> K) -> [T]terminal#

Stable descending order; evaluates the selector exactly once per item.

fn min_by<K>(selector: fn(T) -> K) -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn max_by<K>(selector: fn(T) -> K) -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn sum_by<N>(selector: fn(T) -> N) -> Nterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn average() -> Optional<float>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn average_by(selector: fn(T) -> number) -> Optional<float>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn count_by(predicate: fn(T) -> bool) -> intterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn fold_indexed<U>(initial: U, callback: fn(int, U, T) -> U) -> Uterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn reduce_indexed(callback: fn(int, T, T) -> T) -> Optional<T>terminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn fold_right<U>(initial: U, callback: fn(T, U) -> U) -> Uterminal#

Traverses the array right-to-left; callback order is element, accumulator.

fn reduce_right(callback: fn(T, T) -> T) -> Optional<T>terminal#

Traverses the array right-to-left and returns none for empty input.

fn sum() -> Tterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn min() -> Tterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn max() -> Tterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn join_to_string(sep: string, prefix: string = "", suffix: string = "", limit: int = -1, truncated: string = "...") -> stringterminal#

Consumes an iterator from its current cursor position; array receivers inspect the complete array.

fn push(value: T) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn pop() -> Tmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn set(index: int, value: T) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn insert(index: int, value: T) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn remove_at(index: int) -> Tmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn push_front(value: T) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn pop_front() -> Tmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn clear() -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn add_all(values: [T]) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn remove_value(value: T) -> boolmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn remove_all(values: [T]) -> boolmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn retain_all(values: [T]) -> boolmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn fill(value: T) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn reverse_in_place() -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn sort_in_place() -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.

fn sort_by_in_place<K>(selector: fn(T) -> K) -> voidmutating#

Mutates the receiver array in place. Structural changes invalidate existing cursors.