Iter<T> class

Iter is the union between an Iterator and an Iterable. Most iterator methods are consuming and should be assumed to be so unless otherwise stated.

Inheritance
Implemented types
Available extensions

Constructors

Iter.new(Iterator<T> _wIterator)
Iter.empty()
Iter.fromIterable(Iterable<T> iterable)

Properties

current → T
The current element.
no setteroverride
first → T
The first element.
no setteroverride
firstOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The first element of this iterator, or null if the iterable is empty.
no setter
hashCode int
The hash code for this object.
no setteroverride
indexed Iter<(int, T)>

Available on Iter<T>, provided by the Iter$IterExtensionOverride extension

Returns an Iter over the elements of this iterable, paired with their index.
no setter
indexed Iterable<(int, T)>

Available on Iterable<T>, provided by the IterableExtensions extension

Pairs of elements of the indices and elements of this iterable.
no setter
isEmpty bool
Whether this collection has no elements.
no setteroverride
isNotEmpty bool
Whether this collection has at least one element.
no setteroverride
iterator Iterator<T>
A new Iterator that allows iterating the elements of this Iterable.
no setteroverride
last → T
The last element.
no setteroverride
lastOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The last element of this iterable, or null if the iterable is empty.
no setter
length int
The number of elements in this Iterable.
no setteroverride
nonNulls Iterable<T>

Available on Iterable<T?>, provided by the NullableIterableExtensions extension

The non-null elements of this iterable.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single → T
Checks that this iterable has only one element, and returns that element.
no setteroverride
singleOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The single element of this iterator, or null.
no setter
wait Future<List<T>>

Available on Iterable<Future<T>>, provided by the FutureIterable extension

Waits for futures in parallel.
no setter

Methods

advanceBy(int n) → Result<(), int>
Advances the iterator by n elements. The iterator will have been advanced by n elements when Ok(()) is returned, or a Err(k) where k is remaining number of steps that could not be advanced because the iterator ran out.
all(bool f(T)) bool
any(bool test(T element)) bool
Checks whether any element of this iterable satisfies test.
inherited
arrayChunks(int size) ArrayChunks<T>
Returns an iterator over N elements of the iterator at a time. The chunks do not overlap. If N does not divide the length of the iterator, then the last up to N-1 elements will be omitted and can be retrieved from the .intoRemainder() function of the iterator.
asNameMap() Map<String, T>

Available on Iterable<T>, provided by the EnumByName extension

Creates a map from the names of enum values to the values.
byName(String name) → T

Available on Iterable<T>, provided by the EnumByName extension

Finds the enum value in this list with name name.
cast<U>() Iter<U>
Casts this Iter
override
chain(Iterator<T> other) Chain<T>
Takes two iterators and creates a new iterator over both in sequence.
clone() Iter<T>
An iterator which is a "clone" of the original iterator. Iterating through the original or the clone will not affect the other. Do not modify the original collection the original Iterable is based on while iterating. See Clone for more information.
cmp(Iterator<U> other) int

Available on Iter<T>, provided by the Iter$IterComparableOtherExtension extension

Lexicographically compares the elements of this Iterator with those of another. Less = -1 Equal = 0 Greater = 1
cmpBy<U>(Iterator<U> other, int f(T, U)) int
Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function. Less = -1 Equal = 0 Greater = 1
collectArr() Arr<T>
collectList() List<T>
collectSet() Set<T>
collectVec() Vec<T>

Available on Iterator<T>, provided by the Vec$IteratorExtension extension

contains(Object? element) bool
Whether the collection contains an element equal to element.
inherited
count() int
Counting the number of iterations and returning it.
cycle() Cycle<T>
Creates an iterator which repeats the elements of the original iterator endlessly.
elementAt(int index) → T
Returns the indexth element.
inherited
elementAtOrNull(int index) → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The element at position index of this iterable, or null.
elementAtOrNull(int index) → Never

Available on Iter<T>, provided by the Iter$IterExtensionOverride extension

enumerate() Iter<(int, T)>
Creates an iterator which gives the current iteration count as well as the next value.
eq<U>(Iterator<U> other) bool
Determines if the elements of this Iterator are equal to those of another using "==".
eqBy<U>(Iterator<U> other, bool f(T, U)) bool
Determines if the elements of this Iterator are equal to those of another with respect to the specified equality function.
every(bool test(T element)) bool
Checks whether every element of this iterable satisfies test.
inherited
expand<U>(Iterable<U> f(T)) Iter<U>
Expands each element of this Iter into zero or more elements.
override
filter(bool f(T)) Iter<T>
Creates an iterator which uses a closure to determine if an element should be yielded.
filterMap<U>(U? f(T)) Iter<U>

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Creates an iterator that both filters and maps. The returned iterator yields only the values for which the supplied closure returns a non-null value.
filterMapOpt<U>(Option<U> f(T)) Iter<U>
Creates an iterator that both filters and maps. The returned iterator yields only the values for which the supplied closure returns Some(value).
find(bool f(T)) → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Searches for an element of an iterator that satisfies a predicate.
findMap<U>(U? f(T)) → U?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Applies the function to the elements of iterator and returns the first non-(none/null) result.
findMapOpt<U>(Option<U> f(T)) Option<U>
Applies the function to the elements of iterator and returns the first non-(none/null) result.
findOpt(bool f(T)) Option<T>
Searches for an element of an iterator that satisfies a predicate.
firstOrNull() → Never

Available on Iter<T>, provided by the Iter$IterExtensionOverride extension

firstWhere(bool test(T element), {T orElse()?}) → T
The first element that satisfies the given predicate test.
inherited
flatMap<U>(Iterator<U> f(T)) FlatMap<T, U>
Creates an iterator that works like map, but flattens nested structure.
flatten() Iter<T>

Available on Iter<Iterable<T>>, provided by the Iter$IterIterableExtension extension

Flatten an iterator of iterators into a single iterator.
fold<T>(T initialValue, T combine(T previousValue, T element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<T> other) Iter<T>
Creates the lazy concatenation of this Iterator and other
override
forEach(void action(T element)) → void
Invokes action on each element of this iterable in iteration order.
inherited
fuse() Iter<T>

Available on Iter<Option<T>>, provided by the Iter$IterOptionExtension extension

Creates an iterator which ends after the first None.
fuse() Iter<T>

Available on Iter<T?>, provided by the Iter$IterNullableExtension extension

Creates an iterator which ends after the first None.
ge(Iterator<U> other) bool

Available on Iter<T>, provided by the Iter$IterComparableOtherExtension extension

Determines if the elements of this Iterator are lexicographically greater than or equal to those of another.
gt(Iterator<U> other) bool

Available on Iter<T>, provided by the Iter$IterComparableOtherExtension extension

Determines if the elements of this Iterator are lexicographically greater than those of another.
inspect(void f(T)) Iter<T>
Does something with each element of an iterator, passing the value on.
intersperse(T element) Iter<T>
Creates a new iterator which places a separator between adjacent items of the original iterator. Similar to join with strings.
intersperseWith(T f()) Iter<T>
Creates a new iterator which places an item generated by separator between adjacent items of the original iterator. The closure will be called each time to generate the separator.
isPartitioned(bool f(T)) bool
Checks if the elements of this iterator are partitioned according to the given predicate, such that all those that return true precede all those that return false.
isSorted() bool

Available on Iter<T>, provided by the Iter$IterComparableSelfExtension extension

Checks if the elements of this iterator are sorted. That is, for each element a and its following element b, a <= b must hold. If the iterator yields exactly zero or one element, true is returned.
isSortedBy(int f(T, T)) bool
Checks if the elements of this iterator are sorted by f. That is, for each element f(a,b) and its following element f(b,c), f(a,b) <= f(b,c) must hold. If the iterator yields exactly zero or one element, true is returned. negative if a < b zero if a == b positive if a > b
isSortedByKey<U extends Comparable<U>>(U f(T)) bool
Checks if the elements of this iterator are sorted by a key. That is, for each element f(a) and its following element f(b), f(a) <= f(b) must hold. If the iterator yields exactly zero or one element, true is returned. negative if a < b zero if a == b positive if a > b
iter() Iter<T>

Available on Iterable<T>, provided by the Iter$IterableExtension extension

Returns an Iter over the Iterable.
iter() Iter<T>

Available on Iterator<T>, provided by the Iter$IteratorExtension extension

Returns an Iter for this Iterator.
join([String separator = ""]) String
Converts each element to a String and concatenates the strings.
inherited
lastOrNull() → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Consumes the iterator and returns the last element.
lastOrNull() → T?

Available on Iter<T>, provided by the Iter$IterExtensionOverride extension

Returns the last element of this iterable, or null if the iterable is empty.
lastOrOption() Option<T>
Consumes the iterator and returns the last element.
lastWhere(bool test(T element), {T orElse()?}) → T
The last element that satisfies the given predicate test.
inherited
le(Iterator<U> other) bool

Available on Iter<T>, provided by the Iter$IterComparableOtherExtension extension

Determines if the elements of this Iterator are lexicographically less or equal to those of another.
lt(Iterator<U> other) bool

Available on Iter<T>, provided by the Iter$IterComparableOtherExtension extension

Determines if the elements of this Iterator are lexicographically less than those of another.
map<U>(U f(T)) Iter<U>
Maps each element of this Iter to a new Iter
override
mapWhile<U>(U? f(T)) Iter<U>

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Creates an iterator that both yields elements based on a predicate and maps. It will call this closure on each element of the iterator, and yield elements while it returns Some(_).
mapWhileOpt<U>(Option<U> f(T)) Iter<U>
Creates an iterator that both yields elements based on a predicate and maps. It will call this closure on each element of the iterator, and yield elements while it returns Some(_).
mapWindows<U>(int size, U f(Arr<T>)) Iter<U>
Calls the given function f for each contiguous window of size over self and returns an iterator over the outputs of f e.g. 1, 2, 3, 4 with size 2 will yield windows of 1, 2, 2, 3, 3, 4
max() → T?

Available on Iter<T>, provided by the Iter$IterComparableSelfExtension extension

Returns the maximum element of an iterator.
maxBy(int f(T, T)) → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Returns the element that gives the maximum value with respect to the specified comparison function.
maxByKey<U extends Comparable<U>>(U f(T)) → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Returns the element that gives the maximum value from the specified function.
maxByKeyOpt<U extends Comparable<U>>(U f(T)) Option<T>
Returns the element that gives the maximum value from the specified function.
maxByOpt(int f(T, T)) Option<T>
Returns the element that gives the maximum value with respect to the specified comparison function.
maxOpt() Option<T>

Available on Iter<T>, provided by the Iter$IterComparableSelfExtension extension

Returns the maximum element of an iterator.
merge() Result<List<S>>

Available on Iterable<Result<S>>, provided by the AnyhowIterableResultExtension extension

Merges an Iterable of results into a single result where the Ok value is the list of all successes. If any Error is encountered, the first Error becomes the root to the rest of the Errors. Similar to toResult.
min() → T?

Available on Iter<T>, provided by the Iter$IterComparableSelfExtension extension

Returns the minimum element of an iterator.
minBy(int f(T, T)) → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Returns the element that gives the minimum value with respect to the specified comparison function.
minByKey<U extends Comparable<U>>(U f(T)) → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Returns the element that gives the minimum value from the specified function.
minByKeyOpt<U extends Comparable<U>>(U f(T)) Option<T>
Returns the element that gives the minimum value from the specified function.
minByOpt(int f(T, T)) Option<T>
Returns the element that gives the minimum value with respect to the specified comparison function.
minOpt() Option<T>

Available on Iter<T>, provided by the Iter$IterComparableSelfExtension extension

Returns the minimum element of an iterator.
moveNext() bool
Advances the iterator to the next element of the iteration.
override
ne(Iterator<U> other) bool

Available on Iter<T>, provided by the Iter$IterComparableOtherExtension extension

Determines if the elements of this Iterator are not equal to those of another.
next() → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

If the iterator is empty, returns null. Otherwise, returns the next value.
nextChunk(int size) → Result<Arr<T>, Iter<T>>
Returns the next n elements of the iterator as an Arr, If there are not enough elements to fill the array then Err is returned containing an iterator over the remaining elements.
nextOpt() Option<T>
If the iterator is empty, returns None. Otherwise, returns the next value wrapped in Some.
nonNulls() Iter<T>

Available on Iter<T?>, provided by the Iter$IterNullableExtensionOverride extension

Returns an Iter over the non-null elements of this iterator.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nth(int n) → T?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Returns the nth element of the iterator. Like most indexing operations, the count starts from zero, so nth(0) returns the first value, nth(1) the second, and so on. nth() will return None if n is greater than or equal to the length of the iterator.
nthOpt(int n) Option<T>
Returns the nth element of the iterator. Like most indexing operations, the count starts from zero, so nth(0) returns the first value, nth(1) the second, and so on. nth() will return None if n is greater than or equal to the length of the iterator.
partition(bool f(T)) → (List<T>, List<T>)
Consumes an iterator, creating two collections from it. partition() returns a pair, all of the elements for which it returned true, and all of the elements for which it returned false.
partitionInPlace(bool f(T)) int
Reorders the elements of this iterator in-place according to the given predicate, such that all those that return true precede all those that return false. Returns the number of true elements found. The relative order of partitioned items is not maintained.
peekable() Peekable<T>
Creates an iterator which can use the "peek" to look at the next element of the iterator without consuming it.
position(bool f(T)) int?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Searches for an element in an iterator, returning its index.
positionOpt(bool f(T)) Option<int>
Searches for an element in an iterator, returning its index.
reduce(T combine(T value, T element)) → T
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
rev() Iter<T>
Reverses the iterable
rposition(bool f(T)) int?

Available on Iter<T>, provided by the Iter$IterConcreteExtension extension

Searches for an element in an iterator from the right, returning its index. Recommended to use with a list, as it is more efficient, otherwise use positionOpt.
rpositionOpt(bool f(T)) Option<int>
Searches for an element in an iterator from the right, returning its index. Recommended to use with a list, as it is more efficient, otherwise use positionOpt.
scan<U>(U initial, Option<U> f(U, T)) Iter<U>
An iterator which, like fold, holds internal state, but unlike fold, produces a new iterator. On iteration, the closure will be applied to each element of the iterator and the return value from the closure. The closure can return Some(value) to yield value, or None to end the iteration.
singleOrNull() → Never

Available on Iter<T>, provided by the Iter$IterExtensionOverride extension

singleWhere(bool test(T element), {T orElse()?}) → T
The single element that satisfies test.
inherited
skip(int count) Iter<T>
Consumes and skips the first count elements.
override
skipWhile(bool f(T)) Iter<T>
Consumes and skips elements while f is true and returns the rest.
override
stepBy(int step) Iter<T>
Creates an iterator starting at the same point, but stepping by the given amount at each iteration.
take(int count) Iter<T>
Takes the first count elements from the Iter.
override
takeWhile(bool f(T)) Iter<T>
TTakes the first count elements from the Iter while f is true.
override
toArr() Arr<T>

Available on Iterable<T>, provided by the Array$IterableExtension extension

Creates an Array from an Iterable
toList({bool growable = true}) List<T>
Creates a List containing the elements of this Iterable.
inherited
toNullables() Iterable<T?>

Available on Iterable<Option<T>>, provided by the Iter$IterableOption extension

toNullables() Iter<T?>

Available on Iter<Option<T>>, provided by the Iter$IterOption extension

toOptions() Iterable<Option<T>>

Available on Iterable<T?>, provided by the Iter$IterableNullable extension

toOptions() Iter<Option<T>>

Available on Iter<T?>, provided by the Iter$IterNullable extension

toResult() Result<List<S>>

Available on Iterable<Result<S>>, provided by the AnyhowIterableResultExtension extension

Transforms an Iterable of results into a single result where the Ok value is the list of all successes. The Err type is an Error with list of all errors List<Error>. Similar to merge.
toResult() → Result<List<S>, List<F>>

Available on Iterable<Result<S, F>>, provided by the Result$IterableResultExtension extension

Transforms an Iterable of results into a single result where the ok value is the list of all successes and err value is a list of all failures.
toResult() → FutureResult<List<S>, List<F>>

Available on Iterable<FutureResult<S, F>>, provided by the Result$IterableFutureResultExtension extension

Transforms an Iterable of FutureResults into a single result where the ok value is the list of all successes and err value is a list of all failures. The order of S and F is determined by the order in the List.
toResultEager() → Result<List<S>, F>

Available on Iterable<Result<S, F>>, provided by the Result$IterableResultExtension extension

Transforms an Iterable of results into a single result where the ok value is the list of all successes. If any error is encountered, the first error is used as the error result.
toResultEager() → FutureResult<List<S>, F>

Available on Iterable<FutureResult<S, F>>, provided by the Result$IterableFutureResultExtension extension

Transforms an Iterable of FutureResults into a single result where the ok value is the list of all successes. If any error is encountered, the first error is used as the error result. The order of S and F is determined by the order in which futures complete.
toSet() Set<T>
Creates a Set containing the same elements as this iterable.
inherited
toString() String
Returns a string representation of (some of) the elements of this.
inherited
toVec() Vec<T>

Available on Iterable<T>, provided by the Vec$IterableExtension extension

tryCollect() → Result<List<T>, E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

Transforms an iterator into a collection, short circuiting if a Err is encountered.
tryFind(bool f(T)) → Result<T?, E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

Applies function to the elements of iterator and returns the first true result or the first Err element.
tryFind<E extends Object>(Result<bool, E> f(T)) → Result<T?, E>

Available on Iter<T>, provided by the Iter$IterExtension extension

Applies function to the elements of iterator and returns the first true result or the first error.
tryFindOpt(bool f(T)) → Result<Option<T>, E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

Applies function to the elements of iterator and returns the first true result or the first Err element.
tryFindOpt<E extends Object>(Result<bool, E> f(T)) → Result<Option<T>, E>

Available on Iter<T>, provided by the Iter$IterExtension extension

Applies function to the elements of iterator and returns the first true result or the first error.
tryFold<U>(U initial, U f(U, T)) → Result<U, E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

An iterator method that applies a function producing a single value, returns Err is encountered.
tryFold<U, E extends Object>(U initial, Result<U, E> f(U, T)) → Result<U, E>

Available on Iter<T>, provided by the Iter$IterExtension extension

An iterator method that applies a function as long as it returns successfully, producing a single, final value.
tryForEach(void f(T)) → Result<(), E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

An iterator method that applies a function, stopping at the first Err and returning that Err.
tryForEach<E extends Object>(Result<(), E> f(T)) → Result<(), E>

Available on Iter<T>, provided by the Iter$IterExtension extension

An iterator method that applies a fallible function to each item in the iterator, stopping at the first error and returning that error.
tryReduce(T f(T, T)) → Result<T?, E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

Reduces the elements to a single one by repeatedly applying a reducing operation. If a Err is encountered it is returned.
tryReduce<E extends Object>(Result<T, E> f(T, T)) → Result<T?, E>

Available on Iter<T>, provided by the Iter$IterExtension extension

Reduces the elements to a single one by repeatedly applying a reducing operation. If the closure returns a failure, the failure is propagated back to the caller immediately.
tryReduceOpt(T f(T, T)) → Result<Option<T>, E>

Available on Iter<Result<T, E>>, provided by the Iter$IterResultExtension extension

Reduces the elements to a single one by repeatedly applying a reducing operation. If a Err is encountered it is returned.
tryReduceOpt<E extends Object>(Result<T, E> f(T, T)) → Result<Option<T>, E>

Available on Iter<T>, provided by the Iter$IterExtension extension

Reduces the elements to a single one by repeatedly applying a reducing operation. If the closure returns a failure, the failure is propagated back to the caller immediately.
unzip() → (List<T>, List<U>)

Available on Iter<(T, U)>, provided by the Iter$IterRecord2Extension extension

Converts an iterator of pairs into a pair of containers.
where(bool f(T)) Iter<T>
Creates an Iter where all the elements satisfy the predicate f.
override
whereType<U>() Iter<U>
Creates an Iter where all the elements are of Type U.
override
zip<U>(Iterator<U> other) Zip<T, U>

Operators

operator ==(Object other) bool
The equality operator.
override