RevGrid - v0.10.0
    Preparing search index...

    Manages a list of non-overlapping, non-abutting, and ordered contiguous index ranges.

    This class provides methods to add, delete, and query ranges of indices, as well as to adjust the ranges in response to insertions, deletions, and moves of indices. Ranges are represented by RevContiguousIndexRange objects and are always kept in order by their starting index.

    Key features:

    • Ranges do not overlap or abut, and are always ordered by their start index.
    • Supports adding and deleting ranges, with automatic merging and splitting as needed.
    • Provides methods to check for inclusion, count indices, and enumerate all indices.
    • Can adjust ranges for inserted, deleted, or moved indices, maintaining consistency.

    Used to manage row and column selections.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    subgrid: RevSubgrid<BCS, SF>

    Accessors

    • get areaCount(): number

      Returns number

    Methods

    • Adds a contiguous range of indices to the list, merging with existing ranges if necessary.

      The range is specified by an start or excluded end index, and a length. If the length is negative, the range is added in reverse order (excluding the start index). The method ensures that overlapping or adjacent ranges are merged into a single range, and prevents adding a range that is already fully contained within an existing range.

      Parameters

      • startOrExEnd: number

        The starting index of the range to add if length is positive, or the exclusive end index if length is negative.

      • length: number

        The length of the range. If negative, the range is specified from its exclusive end.

      Returns boolean

      true if the range was added or merged; false if the range was already contained and no change was made.

    • Adjusts the list of contiguous index ranges to account for a deletion of items.

      This method updates the internal ranges to reflect the removal of a contiguous block of items, starting at the specified start index and spanning count items. It shifts, shrinks, or removes ranges as necessary to maintain consistency after the deletion. If any ranges are fully enclosed within the deleted region, they are removed. Ranges that overlap the deleted region are shrunk, and ranges above the deleted region are shifted down. If possible, adjacent ranges are merged after the adjustment.

      Parameters

      • start: number

        The starting index of the deleted region.

      • count: number

        The number of contiguous items deleted.

      Returns boolean

      true if any ranges were changed as a result of the deletion; otherwise, false.

    • Adjusts the index ranges in the list to account for the insertion of new items.

      This method updates all ranges that are at or above the insertion point by moving them up by the specified count. If the insertion point falls within an existing range, that range is grown to include the new items.

      Parameters

      • start: number

        The index at which new items are inserted.

      • count: number

        The number of items inserted.

      Returns boolean

      true if any ranges were changed; otherwise, false.

    • Adjusts the current index ranges to account for a contiguous block of items being moved from one position to another within a collection.

      This method first removes the specified range from its old position, then inserts it at the new position. It returns whether any changes were made to the selection as a result of the move.

      Parameters

      • oldIndex: number

        The starting index of the block being moved.

      • newIndex: number

        The index at which the block should be inserted.

      • count: number

        The number of contiguous items being moved.

      Returns boolean

      true if the selection was changed as a result of the move; otherwise, false.

    • Calculates and returns the first overlapping range between the given range and the existing ranges.

      Given a starting index (or exclusive end index) and a length, this method searches the list of contiguous index ranges in order and returns the first range that overlaps with the specified range.

      Parameters

      • startOrExEnd: number

        The starting index of the range, or the exclusive end index if length is negative.

      • length: number

        The length of the range. If negative, the range is specified from its exclusive end.

      Returns undefined | RevContiguousIndexRange

      A new RevContiguousIndexRange representing the first overlapping range, or undefined if there is no overlap.

    • Calculates the last overlapping range between the specified range and the existing ranges.

      Given a starting index (or exclusive end index) and a length, this method searches the list of contiguous index ranges in reverse order and returns the last range that overlaps with the specified range.

      Parameters

      • startOrExEnd: number

        The starting index of the range if length is positive, or the exclusive end index if length is negative.

      • length: number

        The length of the range. If negative, the range is specified from its exclusive end.

      Returns undefined | RevContiguousIndexRange

      A new RevContiguousIndexRange representing the last overlapping range, or undefined if there is no overlap.

    • Calculates and returns the first or last overlapping range between the given range and the existing ranges. If the length is non-negative, it calculates the first overlapping range. If the length is negative, it calculates the last overlapping range.

      Parameters

      • startOrExEnd: number

        The starting index or exclusive ending index of the range to check for overlap.

      • length: number

        The length of the range. If negative, the range is specified from its exclusive end.

      Returns undefined | RevContiguousIndexRange

      The overlapping contiguous index range, or undefined if there is no overlap.

    • Removes all index ranges from the list, effectively clearing the selection.

      Returns void

    • Deletes a contiguous range of indices from the selection.

      The method updates the internal ranges to reflect the deletion, splitting or resizing ranges as necessary.

      Parameters

      • startOrExEnd: number

        The starting index of the range to delete if length is positive, or the exclusive end index if length is negative.

      • length: number

        The length of the range. If negative, the range is specified from its exclusive end.

      Returns boolean

      true if any ranges were deleted or modified; false if the deletion did not affect any ranges.

    • Calculates and returns the total number of indices across all contiguous index ranges.

      Iterates through each range in the ranges array and sums their lengths to determine the total count of selected indices.

      Returns number

      The total count of indices in all ranges.

    • Returns an array containing all indices represented by the current list of contiguous index ranges. The indices are collected from each range in order and combined into a single array.

      Returns number[]

      An array of indices covered by all ranges in this list.

    • Determines whether there are any index ranges present in the list.

      Returns boolean

      true if the list contains at least one range; otherwise, false.

    • Determines whether the list of contiguous index ranges contains more than one index in total.

      Returns boolean

      true if there is more than one index represented in the ranges; otherwise, false.

    • Determines whether the list of contiguous index ranges contains zero, one or more than one index in total.

      Returns -1 | 0 | 1

      0 if there are no indices, 1 if there is one index, or -1 if there is more than one index represented in the ranges.

    • Determines whether the specified index is included within any of the contiguous index ranges.

      Parameters

      • index: number

        The index to check for inclusion.

      Returns boolean

      true if the index is included in any range; otherwise, false.

    • Determines whether the list of contiguous index ranges is empty.

      Returns boolean

      true if there are no ranges in the list; otherwise, false.