Vec$ListExtension<T> extension
A contiguous growable array type, written as Vec
- on
-
- List<
T>
- List<
Methods
-
append(
List< T> other) → void - Adds all of other's elements to this Vec.
-
dedup(
) → void -
Removes consecutive repeated elements in the vector according to
==
. If the vector is sorted, this removes all duplicates. -
dedupBy(
bool f(T a, T b)) → void - Removes all but the first of consecutive elements in the vector satisfying a given equality relation. If the vector is sorted, this removes all duplicates.
-
dedupByKey<
K> (K f(T)) → void - Removes all but the first of consecutive elements in the vector for which the given predicate returns true. If the vector is sorted, this removes all duplicates.
-
drain(
int start, int end) → Vec< T> - Removes the element at the given index from the Vec and returns it.
-
extendFromSlice(
Slice< T> slice) → void - Appends all elements in a slice to the Vec.
-
extendFromWithin(
int start, int end) → void -
extractIf(
bool f(T)) → Iter< T> - Creates an Iter which uses a closure to determine if an element should be removed. If the closure returns true, then the element is removed and yielded. If the closure returns false, the element will remain in the vector and will not be yielded by the iterator.
-
firstOrOption(
) → Option< T> - Returns the first element of an iterator, None if empty.
-
iter(
) → Iter< T> -
lastOrOption(
) → Option< T> - Returns the last element of an iterator, None if empty.
-
len(
) → int - insert: Already implemented by list Returns the length of the Vec. Equivalent to length.
-
pop(
) → Option< T> - Removes the last element from the Vec and returns it, or None if it is empty.
-
push(
T element) → void - Appends an element to the end of the Vec. Equivalent to add.
-
resize(
int newLen, T value) → void -
Resizes the Vec in-place so that len is equal to
newLen
. IfnewLen
is greater than len, the Vec is extended by the difference, with each additional slot filled with value. If new_len is less than len, the Vec is simply truncated. -
resizeWith(
int newLen, T f()) → void -
Resizes the Vec in-place so that len is equal to
newLen
. IfnewLen
is greater than len, the Vec is extended by the difference, with each additional slot filled with the result of f. If new_len is less than len, the Vec is simply truncated. -
retain(
bool f(T)) → void - Retains only the elements specified by the predicate where the result is true. Equivalent to retainWhere.
-
singleOrOption(
) → Option< T> - Returns the single element of an iterator, None if this is empty or has more than one element.
-
splice(
int start, int end, Iterable< T> replaceWith) → Vec<T> -
Creates a splicing iterator that replaces the specified range in the vector with the given
replaceWith
iterator and yields the removed items. replace_with does not need to be the same length as range. -
splitOff(
int at) → Vec< T> - Splits the collection into two at the given index. Returns a newly allocated vector containing the elements in the range [at, len). After the call, the original vector will be left containing the elements [0, at).
-
swapRemove(
int index) → T - Removes an element from the vector and returns it. The removed element is replaced by the last element of the vector.
-
truncate(
int newLen) → void - Shortens the vector, keeping the first len elements and dropping the rest.