Skip to content
Last updated

API / geotoolkit / util / iterator / Iterator

Class: Iterator<T&gt;

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
  • [new Iterator<T&gt;()](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.iterator.iterator.md#new iterator<t>())
Methods

Contents

Constructors

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

• new Iterator<T&gt;()

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&gt;(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&gt;

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&gt;


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&gt;

Resets iterator to its initial state.

Returns

Iterator<T&gt;


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&gt;(array, func, callback?): void

Runs asynchronous function for each element and wait execution

Type parameters

Name
T

Parameters

Name Type Description
arrayT[] | Iterator<T&gt;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&gt;(array, func?): Iterator<T&gt;

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&gt;


getClassName

▸ Static getClassName(): string

Returns

string


getIterator

▸ Static getIterator<T&gt;(parameter): Iterator<T&gt;

Returns iterator by the data

Type parameters

Name
T

Parameters

Name Type Description
parameterT | Iterator<T&gt; | T[]data to iterate

Returns

Iterator<T&gt;


toArray

▸ Static toArray<T&gt;(iterator, maxElements?): T[]

Creates array based on elements to iterate

Type parameters

Name
T

Parameters

Name Type Description
iteratorIterator<T&gt;iterator
Optional maxElementsnumberarray size upper limit

Returns

T[]