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

JsReverseIterator

ES6-style backward iterator

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}`);
}
// iterate keys in reverse order
for (let key of m.keys().backwards()) {
  console.log(`key: ${key}`);
}

Constructor Summary

Public Constructor
public

constructor(container: *)

Method Summary

Public Methods
public

Support for ES6 for-of loops.

public

A forward 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](): JsReverseIterator source

Support for ES6 for-of loops.

public backwards(): JsIterator source

A forward iterator for the same container

Return:

JsIterator

Example:

let m = new TreeMap();
...
// iterate all key-value pairs in direct order
for (let [key, value] of m.backwards().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().backwards();
while (true) {
  let res = it.next();
  if (res.done) {
    break;
  }
  console.log(`key: ${res.value[0]}, value: ${res.value[1]`});
}