Last updated

API / geotoolkit / util / iterator / Iterator

Class: Iterator<T>

util.iterator.Iterator

This abstract class defines the interface of a readonly Iterator. Subclasses are responsible for implementing the actual iteration mechanism.

Type parameters

Name
T

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new Iterator&lt;T&amp;gt;()

new Iterator<T>()

Type parameters

Name
T
Methods

filter

Abstract filter(func): T[]

Returns the elements of an array that meet the condition specified in a callback function.

Parameters

Name Type Description
func(item: T) => booleanfunction to apply to each element

Returns

T[]

Abstract filter<S>(predicate): S[]

Returns the elements of an array that meet the condition specified in a callback function.

Type parameters

Name
S

Parameters

Name Type Description
predicate(value: T) => value is Sfilter function

Returns

S[]

Abstract filter(func): T[]

Parameters

Name Type
func(item: T) => boolean

Returns

T[]


forEach

Abstract forEach(func): Iterator<T>

Executes a method for each item in iterator and return new iterator.

Parameters

Name Type Description
func(item: T) => voidfunction to apply to each element

Returns

Iterator<T>


getClassName

getClassName(): string

Returns

string


hasNext

Abstract hasNext(): boolean

Returns true if the iteration has more elements.

Returns

boolean


Abstract next(): T

Returns the next element in the iteration.

Returns

T


reset

Abstract reset(): Iterator<T>

Resets iterator to its initial state.

Returns

Iterator<T>


toArray

toArray(maxElements?): T[]

Creates array based on iterator items

Parameters

Name Type Description
Optional maxElementsnumberarray size upper limit

Returns

T[]


awaitForEach

Static awaitForEach<T>(array, func, callback?): void

Runs asynchronous function for each element and wait execution

Type parameters

Name
T

Parameters

Name Type Description
arrayT[] | Iterator<T>array of any object or iterator
func(x: T, next: () => void) => voidfunction to apply to each element
Optional callback() => voidfunction to be called at the end of execution

Returns

void


getArrayIterator

Static getArrayIterator<T>(array, func?): Iterator<T>

Returns iterator by array elements

Type parameters

Name
T

Parameters

Name Type Description
arrayT[]of any object
Optional func(item: T) => booleanto filter elements

Returns

Iterator<T>


getClassName

Static getClassName(): string

Returns

string


getIterator

Static getIterator<T>(parameter): Iterator<T>

Returns iterator by the data

Type parameters

Name
T

Parameters

Name Type Description
parameterT | Iterator<T> | T[]data to iterate

Returns

Iterator<T>


toArray

Static toArray<T>(iterator, maxElements?): T[]

Creates array based on elements to iterate

Type parameters

Name
T

Parameters

Name Type Description
iteratorIterator<T>iterator
Optional maxElementsnumberarray size upper limit

Returns

T[]