Class: Iterable

Iterable(iterable)

Utility class allowing to iterate a collection.

Note: This should be used with immutable collections, e.g no add or remove operations should be performed while iterating.

Constructor

new Iterable(iterable)

Constructs new iterable for the provided collection.

Parameters:
Name Type Description
iterable Array.<Object>

the collection to iterate

Author:
  • Mihail Radkov
  • Svilen Velikov
Source:

Methods

hasNext() → {boolean}

Returns if there are elements left to be iterated from the collection.

Use this method before calling next() to avoid out of bounds error.

Source:
Returns:

true if there is at least single element left to iterate or false otherwise

Type
boolean

next() → {Object}

Returns the next object from the iterable collection.

Before invoking this method, check if there are elements to iterate by using hasNext() because if there are no objects left to iterate, the function will blow with an error.

Source:
Throws:

if there are no more elements to be iterated

Type
Error
Returns:

the next iterated object from the collection

Type
Object

reset() → {Iterable}

Resets the iterable to begin from the start as if it was just constructed.

Source:
Returns:

the current iterable for method chaining.

Type
Iterable