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

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.

staticfind<T, TFind> (it:Iterator<T>, f:T ‑> Bool):Null<T>

Refer to thx.Arrays.find.

staticfindOption<T, TFind> (it:Iterator<T>, f:T ‑> Bool):Option<T>

staticfirst<T, TFind> (it:Iterator<T>):Null<T>

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.

staticfoldLeft<A, B> (it:Iterator<A>, zero:B, f:B ‑> A ‑> B):B

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.

staticget<T> (it:Iterator<T>, index:Int):Null<T>

Get the element at the index position.

staticgetOption<T> (it:Iterator<T>, index:Int):Option<T>

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.

staticinline isEmpty<T> (it:Iterator<T>):Bool

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.

staticlast<T, TFind> (it:Iterator<T>):Null<T>

Refer to thx.Arrays.last.

staticmap<T, S> (it:Iterator<T>, f:T ‑> S):Array<S>

Refer to Array.map.

staticmapi<T, S> (it:Iterator<T>, f:T ‑> Int ‑> S):Array<S>

Refer to thx.Arrays.mapi.

staticorder<T> (it:Iterator<T>, sort:T ‑> T ‑> Int):Array<T>

staticreduce<TElement, TAcc> (it:Iterator<TElement>, callback:TAcc ‑> TElement ‑> TAcc, initial:TAcc):TAcc

staticreducei<TElement, TAcc> (it:Iterator<TElement>, callback:TAcc ‑> TElement ‑> Int ‑> TAcc, initial:TAcc):TAcc

statictakeUntil<A> (it:Iterator<A>, f:A ‑> Bool):Array<A>

Take values until the first time fn produced false.

statictoArray<T> (it:Iterator<T>):Array<T>

toArray transforms an Iterator<T> into an Array<T>.

staticunzip<T1, T2> (it:Iterator<Tuple2<T1, T2>>):Tuple2<Array<T1>, Array<T2>>

Unzip an iterator of Tuple2 to a Tuple2, Array>.

staticunzip3<T1, T2, T3> (it:Iterator<Tuple3<T1, T2, T3>>):Tuple3<Array<T1>, Array<T2>, Array<T3>>

Unzip an iterator of Tuple3 to a Tuple3, Array, Array>.

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 to a Tuple4, Array, Array, Array>.

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 to a Tuple5, Array, Array, Array, Array>.

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.

staticzip4<T1, T2, T3, T4> (it1:Iterator<T1>, it2:Iterator<T2>, it3:Iterator<T3>, it4:Iterator<T4>):Array<Tuple4<T1, T2, T3, T4>>

Pairs the elements of four iterators in an array of Tuple4.

staticzip5<T1, T2, T3, T4, T5> (it1:Iterator<T1>, it2:Iterator<T2>, it3:Iterator<T3>, it4:Iterator<T4>, it5:Iterator<T5>):Array<Tuple5<T1, T2, T3, T4, T5>>

Pairs the elements of five iterators in an array of Tuple5.