class Iterators
package thx
Helper class to work with Iterator
.
For documentation of specific methods refer to the equivalent methods in thx.Arrays
;
Static methods
staticall<T> (it:Iterator<T>, predicate:T ‑> Bool):Bool
Checks if predicate
returns true for all elements in the iterator.
staticany<T> (it:Iterator<T>, predicate:T ‑> Bool):Bool
Checks if predicate
returns true for at least one element in the iterator.
staticdropUntil<A> (it:Iterator<A>, f:A ‑> Bool):Array<A>
Drop values until the first time fn
produces false.
staticeachPair<TIn, TOut> (it:Iterator<TIn>, handler:TIn ‑> TIn ‑> Bool):Void
Refer to thx.Arrays.eachPair
.
staticequals<T> (a:Iterator<T>, b:Iterator<T>, ?equality:T ‑> T ‑> Bool):Bool
It compares the lengths and elements of two given iterators and returns true
if they match.
An optional equality function can be passed as the last argument. If not provided, strict equality is adopted.
staticfilter<TElement> (it:Iterator<TElement>, predicate:TElement ‑> Bool):Array<TElement>
Refer to Array.filter
.
staticfmap<T, S> (it:Iterator<T>, f:T ‑> S):Iterator<S>
Produce a new Iterator that lazily applies the provided function to each element of this iterator.
staticfmapi<T, S> (it:Iterator<T>, f:T ‑> Int ‑> S):Iterator<S>
Produce a new Iterator that lazily applies the provided function to each element of this iterator and an index value that increases with each application.
staticfoldMap<A, B> (it:Iterator<A>, f:A ‑> B, m:Monoid<B>):B
Fold by mapping the contained values into some monoidal type and reducing with that monoid.
staticforEach<A> (it:Iterator<A>, proc:A ‑> Void):Void
Effectful traversal. Use this instead of .map if producing side-effects. This method consumes the original iterator.
staticinline hasElements<T> (it:Iterator<T>):Bool
Returns true
if the iterator contains at least one element.
staticindexOf<T> (it:Iterator<T>, element:T):Int
Returns the position of element in the iterator. It returns -1 if not found.
staticisIterator (v:Dynamic):Bool
isIterator
checks that the passed argument has all the requirements to be an Iterator
.
Note that no type checking is performed at runtime, the method only checks that the value
has two fields next
and hasNext
and that they are both functions.
staticreduce<TElement, TAcc> (it:Iterator<TElement>, callback:TAcc ‑> TElement ‑> TAcc, initial:TAcc):TAcc
Refer to thx.Arrays.reduce
.
staticreducei<TElement, TAcc> (it:Iterator<TElement>, callback:TAcc ‑> TElement ‑> Int ‑> TAcc, initial:TAcc):TAcc
Refer to thx.Arrays.reducei
.
statictakeUntil<A> (it:Iterator<A>, f:A ‑> Bool):Array<A>
Take values until the first time fn
produced false.
staticunzip<T1, T2> (it:Iterator<Tuple2<T1, T2>>):Tuple2<Array<T1>, Array<T2>>
Unzip an iterator of Tuple2
staticunzip3<T1, T2, T3> (it:Iterator<Tuple3<T1, T2, T3>>):Tuple3<Array<T1>, Array<T2>, Array<T3>>
Unzip an iterator of Tuple3
staticunzip4<T1, T2, T3, T4> (it:Iterator<Tuple4<T1, T2, T3, T4>>):Tuple4<Array<T1>, Array<T2>, Array<T3>, Array<T4>>
Unzip an iterator of Tuple4
staticunzip5<T1, T2, T3, T4, T5> (it:Iterator<Tuple5<T1, T2, T3, T4, T5>>):Tuple5<Array<T1>, Array<T2>, Array<T3>, Array<T4>, Array<T5>>
Unzip an iterator of Tuple5
staticzip<T1, T2> (it1:Iterator<T1>, it2:Iterator<T2>):Array<Tuple2<T1, T2>>
Pairs the elements of two iterators in an array of Tuple2
.
staticzip3<T1, T2, T3> (it1:Iterator<T1>, it2:Iterator<T2>, it3:Iterator<T3>):Array<Tuple3<T1, T2, T3>>
Pairs the elements of three iterators in an array of Tuple3
.