RevGrid - v0.9.3
    Preparing search index...

    Provides fast mappings between array locations, including imbalanced mappings where records are absent from one side

    Index

    Constructors

    Accessors

    • get leftCount(): number

      Gets the number of indexes on the left

      Returns number

    • get rightCount(): number

      Gets the number of indexes on the right

      Returns number

    Methods

    • Inserts a new record at both the left and right indexes

      Parameters

      • leftIndex: undefined | number

        The left index of the new record

      • rightIndex: undefined | number

        The right index of the new record

      Returns void

      O(Log(N)+Log(M)) where N and M are left and right lengths, plus array update

    • Clears the index

      Returns void

    • Retrieves the left index of a record

      Parameters

      • rightIndex: number

        The right index of the record

      Returns undefined | number

      O(Log(N)) where N is the right length, worst O(N + Log(M)) where N and M are the left and right lengths

    • Find the nearest valid left index to the left index

      Parameters

      • rightIndex: number

        The right index of the record

      Returns number

      Approximately O(Log(N)) where N is the left length, worst O(Log(N) + M) where N and M are the left and right lengths

    • Find the nearest valid right index to the left index

      Parameters

      • leftIndex: number

      Returns number

      Approximately O(Log(N)) where N is the left length

    • Retrieves the right index of a record

      Parameters

      • leftIndex: number

        The left index of the record

      Returns undefined | number

      O(Log(N)) where N is the right length

    • Efficiently repopulates the mappings as if left and right indexes are one-to-one (no relocations)

      Parameters

      • length: number

        The number of records to map

      Returns void

      O(N) where N is the length

    • Replace the index with mappings for the given records

      Type Parameters

      • T

      Parameters

      • left: readonly T[]

        The records in their left positions

      • right: readonly T[]

        The records in the right positions

      Returns void

      O(N Log(M)) where N is the left length, and M is the right

    • Validates and removes a record given both left and right indexes

      Parameters

      • leftIndex: undefined | number

        The left index of the record to remove

      • rightIndex: undefined | number

        The right index of the record to remove

      Returns void

      O(1), plus array update. Both left and right indexes must correspond

      Error when the left and right indexes do not match the same record

    • Removes all records based on the left and right indexes given

      Parameters

      • left: (undefined | number)[]
      • right: (undefined | number)[]

      Returns void

    • Removes a record based on the left index

      Parameters

      • leftIndex: number

        The left index of the record to remove

      Returns undefined | number

      O(Log(N)) where N is the right length, plus array update

    • Removes a record based on the right index

      Parameters

      • rightIndex: number

        The right index of the record to remove

      Returns undefined | number

      O(Log(N)) where N is the left length, plus array update

    • The right index of the record may have changed, update it

      Parameters

      • leftIndex: number

        The left index of the record to update

      • rightIndex: null | number

        The new right index to apply

      Returns null | number

      The old right index of the record

      O(Log(N)+Log(M)) where N and M are left and right lengths. The right index should be the location before the insert is performed

    • The left index of the record may have changed, update it

      Parameters

      • leftIndex: null | number

        The new left index to apply

      • rightIndex: number

        The right index of the record to update

      Returns null | number

      The old left index of the record

      O(Log(N)+Log(M)) where N and M are left and right lengths. The left index should be the location before the insert is performed

    • Returns void

    • Parameters

      • nodes: number[]
      • changes: Map<number, number>

      Returns void

    • Attempts to insert a reference at a specific index in an array

      Parameters

      • nodes: number[]

        The array to insert into

      • nodeIndex: number

        The index to insert at

      Returns number

      The new reference number, or -1 if there was no space

    • Redistributes reference numbers to make space at a specific index

      Parameters

      • nodes: number[]

        The array to redistribute

      • index: number

        The index we need to make space at

      Returns Map<number, number>

      A map of old to new reference numbers

    • Performs a binary search for a specific reference number

      Parameters

      • nodes: number[]

        The array to search

      • ref: number

        The reference number to search for

      Returns number

      The index of the reference number

      Error when the reference number is not found