TS-Scribe - v0.6.2
    Preparing search index...

    Class SortedList<ValueType>

    A binary sorted list. This list keeps items sorted according to a custom compare function or the default comparison (based on string value).

    Type Parameters

    • ValueType
    Index

    Accessors

    • get size(): number

      The number of entries in the sorted list.

      Returns number

      The number of items in the list.

    Constructors

    Methods

    • Returns a new iterator object that yields the list values.

      Returns IterableIterator<ValueType>

      An iterable iterator for the list values, same as values().

    • Insert a value in order (before duplicates if they exist).

      Parameters

      • value: ValueType

        The value to insert into the list.

      Returns this

      The instance of the SortedList with the new value added.

    • Get the value at the specified index.

      Parameters

      • index: number

        The index of the value to retrieve.

      Returns ValueType | undefined

      The value at the given index or undefined if the index is out of bounds.

    • Parameters

      • a_: any
      • b_: any

      Returns number

    • Remove the value (only the first occurrence if duplicates exist).

      Parameters

      Returns boolean

      True if the value was removed, otherwise false.

    • Remove the entry at the specified index.

      Parameters

      • index: number

        The index of the value to remove.

      Returns ValueType | undefined

      The removed value or undefined if the index is out of bounds.

    • Call the callback function once for each entry in the list.

      Parameters

      • callback: (value: ValueType, index: number, list: this) => void

        The callback function to call on each entry.

      Returns void

    • Check if the value exists in the list.

      Parameters

      Returns boolean

      True if the value exists, otherwise false.

    • Search for the entry that matches the value, or the next greater entry if no exact match is found.

      Parameters

      Returns [index: number, isMatch: boolean]

      An array where the first element is the index, and the second element is a boolean indicating if an exact match was found.

    • Get a slice of the list as a new sorted list, selected from start to end.

      Parameters

      • Optionalstart: number

        The starting index (inclusive).

      • Optionalend: number

        The ending index (exclusive).

      Returns SortedList<ValueType>

      A new SortedList containing the sliced portion of the list.

    • Returns a new iterator object that yields the list values.

      Returns IterableIterator<ValueType>

      An iterable iterator for the list values.