Class IndexRangeUtil

    • Constructor Detail

      • IndexRangeUtil

        public IndexRangeUtil()
    • Method Detail

      • mergeIndexRanges

        public static List<IndexRange> mergeIndexRanges​(Collection<IndexRange> ranges)
        Merges overlapping or consecutive IndexRange instances from the given collection.

        The method sorts the provided ranges by their start index, then iteratively merges ranges that either overlap or are directly adjacent. The result is a list of non-overlapping and consolidated IndexRange instances.

        Parameters:
        ranges - the collection of IndexRange instances to merge.
        Returns:
        a list of merged IndexRange instances. If the input is null or empty, an empty list is returned.