View source

class thx.Iterators

Available on all platforms

Helper class to work with Iterator.

For documentation of specific methods refer to the equivalent methods in thx.Arrays;

Class Fields

static function all<T>(it:Iterator<T>, predicate:T -> Bool):Bool

Checks if predicate returns true for all elements in the iterator.

static function any<T>(it:Iterator<T>, predicate:T -> Bool):Bool

Checks if predicate returns true for at least one element in the iterator.

static function eachPair<TIn, TOut>(it:Iterator<TIn>, handler:TIn -> TIn -> Bool):Void

static function equals<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.

static function filter<TElement>(it:Iterator<TElement>, predicate:TElement -> Bool):Array<TElement>

Refer to Array.filter.

static function find<T, TFind>(it:Iterator<T>, f:T -> Bool):Null<T>

Refer to thx.Arrays.find.

static function first<T, TFind>(it:Iterator<T>):Null<T>

static function get<T>(it:Iterator<T>, index:Int):Null<T>

Get the element at the index position.

static inline function hasElements<T>(it:Iterator<T>):Bool

Returns true if the iterator contains at least one element.

static function indexOf<T>(it:Iterator<T>, element:T):Int

Returns the position of element in the iterator. It returns -1 if not found.

static inline function isEmpty<T>(it:Iterator<T>):Bool

static function isIterator(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.

static function last<T, TFind>(it:Iterator<T>):Null<T>

Refer to thx.Arrays.last.

static function map<T, S>(it:Iterator<T>, f:T -> S):Array<S>

Refer to

static function mapi<T, S>(it:Iterator<T>, f:T -> Int -> S):Array<S>

Refer to thx.Arrays.mapi.

static function order<T>(it:Iterator<T>, sort:T -> T -> Int):Array<T>

static function reduce<TElement, TAcc>(it:Iterator<TElement>, callback:TAcc -> TElement -> TAcc, initial:TAcc):TAcc

static function reducei<TElement, TAcc>(it:Iterator<TElement>, callback:TAcc -> TElement -> Int -> TAcc, initial:TAcc):TAcc

static function toArray<T>(it:Iterator<T>):Array<T>

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

static function unzip<T1, T2>(it:Iterator<Tuple2<T1, T2>>):Tuple2<Array<T1>, Array<T2>>

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

static function unzip3<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>.

static function unzip4<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>.

static function unzip5<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>.

static function zip<T1, T2>(it1:Iterator<T1>, it2:Iterator<T2>):Array<Tuple2<T1, T2>>

Pairs the elements of two iterators in an array of Tuple2.

static function zip3<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.

static function zip4<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.

static function zip5<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.

Toggle inherited fields