View source

class thx.Iterables

Available on all platforms

Helper class for Iterable. Implementations usually fallback on thx.Iterators.

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

Class Fields

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

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

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

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

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

static inline function equals<T>(a:Iterable<T>, b:Iterable<T>, ?equality:T -> T -> Bool):Bool

It compares the lengths and elements of two given iterables 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 inline function extrema<A>(it:Iterable<A>, ord:Ord<A>):Option<Tuple<A, A>>

extrema finds both the minimum and maximum value included in the iterable, as compared by the specified ordering.

static function extremaBy<A, B>(it:Iterable<A>, f:A -> B, ord:Ord<B>):Option<Tuple<A, A>>

extremaBy finds both the minimum and maximum value included in the iterable, as compared by some function of the values contained within the iterable and the specified ordering.

static inline function filter<T>(it:Iterable<T>, predicate:T -> Bool):Array<T>

Refer to Array.filter.

static inline function find<T, TFind>(it:Iterable<T>, predicate:T -> Bool):Null<T>

Refer to thx.Arrays.find.

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

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

Get the element at the index position.

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

Returns true if the iterable contains at least one element.

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

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

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

static function isIterable(v:Dynamic):Bool

isIterable checks that the passed argument has all the requirements to be an Iterable.

Note that no type checking is performed at runtime, only if a method iterator exists regardless of its signature.

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

Refer to thx.Arrays.last.

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

Refer to Array.map.

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

Refer to thx.Arrays.mapi.

static inline function max<A>(it:Iterable<A>, ord:Ord<A>):Option<A>

max finds the maximum value included in the iterable, accorrding to the specified ordering.

static inline function maxBy<A, B>(it:Iterable<A>, f:A -> B, ord:Ord<B>):Option<A>

maxBy finds the maximum value included in the iterable, as compared by some function of the values contained within the iterable.

static inline function min<A>(it:Iterable<A>, ord:Ord<A>):Option<A>

min finds the minimum value included in the iterable, accorrding to the specified ordering.

static function minBy<A, B>(it:Iterable<A>, f:A -> B, ord:Ord<B>):Option<A>

minBy finds the minimum value included in the iterable, as compared by some function of the values contained within the iterable.

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

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

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

static inline function toArray<T>(it:Iterable<T>):Array<T>

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

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

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

static function unzip3<T1, T2, T3>(it:Iterable<Tuple3<T1, T2, T3>>):Tuple3<Array<T1>, Array<T2>, Array<T3>>

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

static function unzip4<T1, T2, T3, T4>(it:Iterable<Tuple4<T1, T2, T3, T4>>):Tuple4<Array<T1>, Array<T2>, Array<T3>, Array<T4>>

Unzip an iterable of Tuple4 to a Tuple4, Array, Array, Array>.

static function unzip5<T1, T2, T3, T4, T5>(it:Iterable<Tuple5<T1, T2, T3, T4, T5>>):Tuple5<Array<T1>, Array<T2>, Array<T3>, Array<T4>, Array<T5>>

Unzip an iterable of Tuple5 to a Tuple5, Array, Array, Array, Array>.

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

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

static function zip3<T1, T2, T3>(it1:Iterable<T1>, it2:Iterable<T2>, it3:Iterable<T3>):Array<Tuple3<T1, T2, T3>>

Pairs the elements of three iterables in an array of Tuple3.

static function zip4<T1, T2, T3, T4>(it1:Iterable<T1>, it2:Iterable<T2>, it3:Iterable<T3>, it4:Iterable<T4>):Array<Tuple4<T1, T2, T3, T4>>

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

static function zip5<T1, T2, T3, T4, T5>(it1:Iterable<T1>, it2:Iterable<T2>, it3:Iterable<T3>, it4:Iterable<T4>, it5:Iterable<T5>):Array<Tuple5<T1, T2, T3, T4, T5>>

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

Toggle inherited fields