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.
The starting index of the range to add if length
is positive, or the exclusive end index if length
is negative.
The length of the range. If negative, the range is specified from its exclusive end.
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.
The starting index of the deleted region.
The number of contiguous items deleted.
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.
The index at which new items are inserted.
The number of items inserted.
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.
The starting index of the block being moved.
The index at which the block should be inserted.
The number of contiguous items being moved.
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.
The starting index of the range, or the exclusive end index if length
is negative.
The length of the range. If negative, the range is specified from its exclusive end.
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.
The starting index of the range if length
is positive, or the exclusive end index if length
is negative.
The length of the range. If negative, the range is specified from its exclusive end.
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.
The starting index or exclusive ending index of the range to check for overlap.
The length of the range. If negative, the range is specified from its exclusive end.
The overlapping contiguous index range, or undefined
if there is no overlap.
Removes all index ranges from the list, effectively clearing the selection.
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.
The starting index of the range to delete if length
is positive, or the exclusive end index if length
is negative.
The length of the range. If negative, the range is specified from its exclusive end.
true
if any ranges were deleted or modified; false
if the deletion did not affect any ranges.
Searches for and returns the first contiguous index range that includes the specified index.
The index to search for within the list of contiguous index ranges.
The RevContiguousIndexRange that contains the given index, or undefined
if no such range exists.
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.
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.
An array of indices covered by all ranges in this list.
Determines whether there are any index ranges present in the list.
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.
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.
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.
The index to check for inclusion.
true
if the index is included in any range; otherwise, false
.
Determines whether the list of contiguous index ranges is empty.
true
if there are no ranges in the list; otherwise, false
.
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:
Used to manage row and column selections.