A splay tree set is a self-balancing binary search tree that does not allow duplicate items.
The value of a splay tree is in it's amortized O(log n) for all insert, delete min/max,
and find min/max operations.
Usage
import { VectorSet } from'gis-tools-ts';
constvecSet = newVectorSet<number>([], (a, b) =>a - b);
// If the item already exists, the existing item will be returned otherwise // the new item will be both added and returned letitem = vecSet.add(1); vecSet.add(2);
console.log(vecSet.length); // 2 // Get first and last items letfirstitem = vecSet.first(); // 1 letlastitem = vecSet.last(); // 2 // check if a value exists console.log(vecSet.has(1)); // true // look for a value right before one provided console.log(vecSet.lastBefore(2)); // 1 // look for a value right after one provided console.log(vecSet.firstAfter(1)); // 2
Splay Tree Set
Description
A splay tree set is a self-balancing binary search tree that does not allow duplicate items. The value of a splay tree is in it's amortized O(log n) for all insert, delete min/max, and find min/max operations.
Usage
Links