TreeSet is a set of elements ordered by a comparator function. It is implemented as a sorted array.

Example

const treeSet = new TreeSet<number>((a, b) => a - b);
treeSet.setElements([1, 2, 3]);
treeSet.size(); // 3

Type Parameters

  • T

Hierarchy

  • TreeSet

Constructors

Properties

comparator: ((a, b) => number)

Type declaration

    • (a, b): number
    • Parameters

      • a: any
      • b: any

      Returns number

elements: any[]
length: number

Methods

  • Performs a binary search of value in array

    Parameters

    • value: T

      Value to search in array

    Returns number

    If value is found, returns its index in array. Otherwise, returns a negative number indicating where the value should be inserted: -(index + 1)

Generated using TypeDoc