DHUCollectionsExtensions<E> extension

Utility extensions for non-nullable iterables.

on

Properties

halfLength int

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns half the length (floored).
no setter

Methods

associate<K, V>(K keySelector(E), [V valueSelector(E)?]) Map<K, V>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Converts the iterable to a map using keySelector and optional valueSelector.
chunks(int size) List<List<E>>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Splits the iterable into chunks of size size.
concatWithMultipleList(List<Iterable<E>> iterables) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list that concatenates this iterable with iterables.
concatWithSingleList(Iterable<E> iterable) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list that concatenates this iterable with iterable.
containsAll(Iterable<E> collection) bool

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Checks if all elements in the specified collection are contained in this collection.
distinctBy<R>(R keySelector(E), {bool equals(R a, R b)?, int hashCode(R key)?, bool isValidKey(R key)?}) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a new list containing the first occurrence of each distinct element as determined by the key returned from keySelector.
drop(int n) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list containing all elements except the first n elements.
filter(Predicate<E> test) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list containing elements that satisfy test.
filterNot(Predicate<E> test) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list containing elements that do not satisfy test.
find(Predicate<E> predicate) → E?

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns the first element matching predicate, or null if element was not found.
firstHalf() List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns the first half of the iterable.
getRandom([int? seed]) → E

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a random element.
intersperse(E element) Iterable<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Inserts element between every element in the iterable.
mapConcurrent<R>(Future<R> action(E item), {int parallelism = 1}) Future<List<R>>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Executes action on each element with at most parallelism concurrent tasks.
orEmpty() Iterable<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns this iterable (as is) if it is non-null; otherwise, returns an empty iterable.
pairwise() List<(E, E)>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns consecutive pairs from the iterable.
partition(bool predicate(E)) → (List<E>, List<E>)

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Splits the iterable into two lists based on the predicate.
secondHalf() List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns the second half of the iterable.
subtract(Iterable<E> other) Set<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a set of elements contained in this collection but not in other. The returned set preserves the element iteration order of the original collection.
swap(int i, int j) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list with elements at i and j swapped.
takeOnly(int n) List<E>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a list containing the first n elements.
toListConverted<R>() List<R>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Converts this iterable to a list of type R using convert_object logic.
toSetConverted<R>() Set<R>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Converts this iterable to a set of type R using convert_object logic.
windowed(int size, {int step = 1, bool partials = false}) List<List<E>>

Available on Iterable<E>, provided by the DHUCollectionsExtensions extension

Returns a sliding window of size over the iterable.