Class Range


  • public class Range
    extends Object
    Represents a consecutive range of numbers, e.g. a range of selected rows: 1 - 100. Ranges are inclusive of their start value and exclusive of their end value, i.e. start <= x < end
    • Field Detail

      • start

        public int start
      • end

        public int end
    • Constructor Detail

      • Range

        public Range​(int start,
                     int end)
        Create a new Range.
        Parameters:
        start - The start position inclusive.
        end - The end position exclusive.
    • Method Detail

      • size

        public int size()
        Returns:
        The size of this range.
      • contains

        public boolean contains​(int position)
        Check if the given position is contained in this Range.
        Parameters:
        position - the position to check.
        Returns:
        true if the range contains the given position.
      • overlap

        public boolean overlap​(Range range)
        Check if the given Range overlaps this Range.
        Parameters:
        range - The Range to check.
        Returns:
        true if the given Range contains positions that are also contained in this Range.
      • getMembers

        public Set<Integer> getMembers()
        Returns:
        The values represented by this Range.
      • getMembersArray

        public int[] getMembersArray()
        Returns:
        The values represented by this Range.
        Since:
        2.0
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • sortByStart

        public static void sortByStart​(List<Range> ranges)
        Helper method to sort a list of Range objects by their start position.
        Parameters:
        ranges - The Range list to sort.