Update node's key by iterator.
Whether the modification is successful.
const st = new orderedSet([1, 2, 5]);
const iter = st.find(2);
st.updateKeyByIterator(iter, 3); // then st will become [1, 3, 5]
The iterator you want to change.
The key you want to update.
Iterator pointing to the beginning element.
const begin = container.begin();
const end = container.end();
for (const it = begin; !it.equals(end); it.next()) {
doSomething(it.pointer);
}
Iterator pointing to the super end like c++.
const begin = container.begin();
const end = container.end();
for (const it = begin; !it.equals(end); it.next()) {
doSomething(it.pointer);
}
Iterator pointing to the end element.
const rBegin = container.rBegin();
const rEnd = container.rEnd();
for (const it = rBegin; !it.equals(rEnd); it.next()) {
doSomething(it.pointer);
}
Iterator pointing to the super begin like c++.
const rBegin = container.rBegin();
const rEnd = container.rEnd();
for (const it = rBegin; !it.equals(rEnd); it.next()) {
doSomething(it.pointer);
}
An iterator to the first element not less than the given key.
The given key you want to compare.
An iterator to the first element greater than the given key.
The given key you want to compare.
An iterator to the first element not greater than the given key.
The given key you want to compare.
An iterator to the first element less than the given key.
The given key you want to compare.
Iterate over all elements in the container.
container.forEach((element, index) => console.log(element, index));
Callback function like Array.forEach.
Insert a key-value pair or set value by the given key.
The size of container after setting.
const mp = new OrderedMap([[2, 0], [4, 0], [5, 0]]);
const iter = mp.begin();
mp.setElement(1, 0);
mp.setElement(3, 0, iter); // give a hint will be faster.
The key want to insert.
The value want to set.
Optional
hint: OrderedMapIterator<K, V>You can give an iterator hint to improve insertion efficiency.
An iterator pointing to the element if found, or super end if not found.
container.find(1).equals(container.end());
The element you want to find.
Union the other tree to self.
The size of the tree after union.
The other tree container you want to merge.
Removes element by iterator and move iter
to next.
The next iterator.
container.eraseElementByIterator(container.begin());
container.eraseElementByIterator(container.end()); // throw a RangeError
The iterator you want to erase.
new OrderedMap();
new OrderedMap([[0, 1], [2, 1]]);
new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y);
new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y, true);
The initialization container.
Optional
cmp: ((x: K, y: K) => number)The compare function.
Optional
enableIndex: booleanWhether to enable iterator indexing function.
Generated using TypeDoc
Returns
The size of the container.
Example