gis-tools-ts - v0.6.0
    Preparing search index...

    Class VectorSet<T>

    Splay Tree Set

    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.

    import { VectorSet } from 'gis-tools-ts';

    const vecSet = new VectorSet<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
    let item = vecSet.add(1);
    vecSet.add(2);

    console.log(vecSet.length); // 2
    // Get first and last items
    let firstitem = vecSet.first(); // 1
    let lastitem = 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
    • TODO!()

    Type Parameters

    • T
    Index

    Constructors

    Accessors

    • get length(): number

      Returns number

      • the number of items in the set

    Methods

    • Add an item

      Parameters

      • item: T

        the item to add

      Returns T

      • the added item OR if the item already exists, the existing item
    • Delete an item. Return the deleted item if it exists otherwise undefined

      Parameters

      • key: T

        the item

      Returns undefined | T

      • the deleted item
    • Get the first item

      Returns undefined | T

      • the first item, undefined if the set is empty
    • Get the first item in the set that is strictly larger than item. Returns undefined if no item was not found.

      Parameters

      • item: T

        the item to compare against

      Returns undefined | T

      • the first item after the comparison item provided
    • Check if an item exists

      Parameters

      • key: T

        the item

      Returns boolean

      • true if the item exists
    • Get the last item

      Returns undefined | T

      • the last item, undefined if the set is empty
    • Get the last item in the set that is strictly smaller than item. Returns undefined if no item was not found.

      Parameters

      • item: T

        the item to compare against

      Returns undefined | T

      • the last item before the comparison item provided