ListVec<T> extension

A contiguous growable array type, written as Vec

on

Methods

append(List<T> other) → void

Available on List<T>, provided by the ListVec extension

Adds all of other's elements to this Vec.
dedup() → void

Available on List<T>, provided by the ListVec extension

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

Available on List<T>, provided by the ListVec extension

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

Available on List<T>, provided by the ListVec extension

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>

Available on List<T>, provided by the ListVec extension

Removes the element at the given index from the Vec and returns it.
extendFromSlice(Slice<T> slice) → void

Available on List<T>, provided by the ListVec extension

Appends all elements in a slice to the Vec.
extendFromWithin(int start, int end) → void

Available on List<T>, provided by the ListVec extension

extractIf(bool f(T)) Iter<T>

Available on List<T>, provided by the ListVec extension

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>

Available on List<T>, provided by the ListVec extension

Returns the first element of an iterator, None if empty.
iter() Iter<T>

Available on List<T>, provided by the ListVec extension

lastOrOption() Option<T>

Available on List<T>, provided by the ListVec extension

Returns the last element of an iterator, None if empty.
len() int

Available on List<T>, provided by the ListVec extension

insert: Already implemented by list Returns the length of the Vec. Equivalent to length.
pop() Option<T>

Available on List<T>, provided by the ListVec extension

Removes the last element from the Vec and returns it, or None if it is empty.
push(T element) → void

Available on List<T>, provided by the ListVec extension

Appends an element to the end of the Vec. Equivalent to add.
resize(int newLen, T value) → void

Available on List<T>, provided by the ListVec extension

Resizes the Vec in-place so that len is equal to newLen. If newLen 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

Available on List<T>, provided by the ListVec extension

Resizes the Vec in-place so that len is equal to newLen. If newLen 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

Available on List<T>, provided by the ListVec extension

Retains only the elements specified by the predicate where the result is true. Equivalent to retainWhere.
singleOrOption() Option<T>

Available on List<T>, provided by the ListVec extension

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>

Available on List<T>, provided by the ListVec extension

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>

Available on List<T>, provided by the ListVec extension

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

Available on List<T>, provided by the ListVec extension

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

Available on List<T>, provided by the ListVec extension

Shortens the vector, keeping the first len elements and dropping the rest.