Class

TreeIterator

TreeIterator()

STL-like forward iterator. It's more verbose than ES6 iterators, but allows iteration over any part of the container

Constructor

# new TreeIterator()

View Source iterators.ts, line 81

Example
let m = new TreeMap();
...
for (let it = m.begin(); !it.equals(m.end()); it.next()) {
  console.log(`key: ${it.key}, value: ${it.value}`);
}

Members

# __n

__n and __c are defined in the base class

View Source iterators.ts, line 144

Methods

# next() → {void}

Replaces node reference with the reference of the next node in the container. Can be used for manual iteration over a range of key-value pairs.

View Source iterators.ts, line 484

void
Example
let m = new TreeMap();
... // add key-value pairs., using numbers as keys
let from = t.lowerBound(0);
let to = t.upperBound(50);
let it = from;
while (!it.equals(to)) {
  console.log(it.key);
  it.next();
}

# prev() → {void}

Replaces node reference with the reference of the previous node in the container Can be used for manual reverse iteration over a range of key-value pairs.

View Source iterators.ts, line 501

void
Example
let m = new TreeMap();
... // add key-value pairs., using numbers as keys
let from = t.lowerBound(0);
let to = t.upperBound(50);
let it = to;
while (!it.equals(from)) {
  it.prev();
  console.log(it.key);
}