Graphity for TypeScript 3.0.0
    Preparing search index...

    A list of int values in ascending order and without duplicates, as a view of a range of an Int32Array.

    Adjacency lookups such as Graph.outNodes return it, as do other methods of this library that return nodes or edge indices in ascending order, such as Graphs.reachableFrom. It reads like a list, with SortedIntView.get and SortedIntView.size. It is also iterable: for (const node of graph.outNodes(v)). Since its values are sorted and distinct, SortedIntView.indexOf and SortedIntView.contains search in O(log size), and SortedIntView.first and SortedIntView.last are the smallest and the largest value. A loop that must not create an iterator reads size and get(i), or the arrays of Csr directly.

    A view shares its array with the object it comes from instead of copying it; a method that returns a copy, such as SortedIntView.union, says so. Instances are immutable, as the arrays behind them never change. A view that SortedIntView.viewOf makes of an array of the caller stays sorted and unchanged only as long as nobody modifies that range of the array. A view is a plain object of three fields rather than a subarray of an Int32Array, which costs several times as much to create.

    Memory: constant; the values stay in the shared array.

    Implements

    • Iterable<number>
    Index
    EMPTY: SortedIntView = ...

    An empty view.

    • Returns an iterator over the values, in ascending order (Java: iterator(); the list iterator and the spliterator have no counterpart).

      Time: O(1) to create the iterator.

      Returns Iterator<number, undefined>

    • Returns the values as an Int32Array that views the array of this view, without a copy. This is the bridge to code that takes typed arrays. It is not in Java, where the view is itself an IntList.

      The result must not be modified, like the arrays of Csr: it shares its memory with the graph or the result the view comes from.

      Time: O(1).

      Returns Int32Array

    • Returns whether other is a list with the same values in the same order, as the java.util.List contract defines it. A list is another view, an Array or a typed array.

      Time: O(size).

      Parameters

      • other: unknown

      Returns boolean

    • Returns the first value, which is the smallest.

      Time: O(1).

      Returns number

      smallest value

      Error if the view is empty (Java: NoSuchElementException)

    • Calls action for every value, in ascending order.

      Time: O(size).

      Parameters

      • action: (value: number) => void

      Returns void

    • Returns the value at position index (Java: getInt).

      Time: O(1).

      Parameters

      • index: number

        position in 0..size-1

      Returns number

      RangeError if index is out of range

    • Copies length values, from position srcOffset on, into dest at destOffset.

      Time: O(length).

      Parameters

      • srcOffset: number
      • dest: Int32Array
      • destOffset: number
      • length: number

      Returns void

      RangeError if the range to copy is not within this view or not within dest

    • Returns a hash code over the values, as the java.util.List contract defines it. It has the same value as in Java.

      Time: O(size).

      Returns number

    • Returns the position of value, or -1 if the view does not contain it.

      Time: O(log size).

      Parameters

      • value: number

        the value to search for

      Returns number

      position in 0..size-1, or -1

    • Returns the last value, which is the largest.

      Time: O(1).

      Returns number

      largest value

      Error if the view is empty (Java: NoSuchElementException)

    • Returns the values at the positions fromIndex..toIndex-1 as a view of the same array, not a copy.

      Time: O(1).

      Parameters

      • fromIndex: number

        first position

      • toIndex: number

        end position, exclusive

      Returns SortedIntView

      RangeError if fromIndex is negative, toIndex is greater than size, or fromIndex > toIndex

    • Returns the values in dest from position 0 on, or in a new array if dest is null, missing or too short.

      Time: O(size). Memory: 4 x size bytes if it returns a new array, otherwise none.

      Parameters

      • Optionaldest: Int32Array<ArrayBufferLike> | null

        the array to fill, or null or none for a new one

      Returns Int32Array

      dest, or a new array

    • Returns the values as a new array (Java: toIntArray).

      Time: O(size). Memory: 4 x size bytes for the result.

      Returns Int32Array

    • Returns the values of this view and other together, in ascending order and without duplicates.

      The result is a copy, merged on every call, unless one of the two views is empty: then it is the other one.

      Time: O(size + other.size). Memory: up to 4 x (size + other.size) bytes for the result; while it runs, up to as much again if the two views share values.

      Parameters

      Returns SortedIntView

      the union

      Error if the union has more than 2^31 - 9 values, the most an array can hold

    • Returns a view of array[fromIndex..toIndex-1], which must be strictly ascending.

      The range is checked, not copied: the view shares array, and stays sorted and unchanged only as long as nobody modifies that range of it.

      Time: O(toIndex - fromIndex).

      Parameters

      • array: Int32Array

        the array to view

      • fromIndex: number

        first position of the range

      • toIndex: number

        end position of the range, exclusive

      Returns SortedIntView

      a view of the range

      RangeError if fromIndex is negative, toIndex is greater than array.length, or fromIndex > toIndex

      Error if the range is not strictly ascending