Home Reference Source
import {JsIterator} from 'jstreemap/src/public/js-iterators.js'
public class | source

JsIterator

ES6-style forward iterator.

Example:

let m = new TreeMap();
...
for (let [key, value] of m) {
  console.log(`key: ${key}, value: ${value}`);
}
// iterate values
for (let value of m.values()) {
  console.log(`value: ${value}`);
}

Constructor Summary

Public Constructor
public

constructor(container: *)

Method Summary

Public Methods
public

Support for ES6 for-of loops.

public

A reverse iterator for the same container.

public

next(): *

As documented in ES6 iteration protocol.

Public Constructors

public constructor(container: *) source

Params:

NameTypeAttributeDescription
container *

Public Methods

public [Symbol.iterator](): JsIterator source

Support for ES6 for-of loops.

Return:

JsIterator

public backwards(): JsReverseIterator source

A reverse iterator for the same container.

Example:

let m = new TreeMap();
...
// iterate all key-value pairs in reverse order
for (let [key, value] of m.backwards()) {
  console.log(`key: ${key}, value: ${value}`);
}

public next(): * source

As documented in ES6 iteration protocol. It can be used for manual iteration. Iterators are documented here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators

Return:

*

Example:

let m = new TreeMap();
...
let jsIt = m.entries();
while (true) {
  let res = it.next();
  if (res.done) {
    break;
  }
  console.log(`key: ${res.value[0]}, value: ${res.value[1]`});
}