Class IntegerRanges

java.lang.Object
com.pnfsoftware.jeb.util.primitives.IntegerRanges

public class IntegerRanges extends Object
Collection of integer ranges (a range is noted [beg, end) or [beg, end[).
  • Constructor Details

    • IntegerRanges

      public IntegerRanges(boolean mergeRanges)
      Create an empty range collection.
      Parameters:
      mergeRanges - true to merge adjacent ranges automatically
  • Method Details

    • count

      public int count()
      Count the number of stored ranges.
      Returns:
      the range count
    • add

      public void add(int beg, int end)
      Add a non-empty range.
      Parameters:
      beg - inclusive range start
      end - exclusive range end
    • isInsideRange

      public boolean isInsideRange(int v, int[] range)
      Determine whether a value belongs to one of the stored ranges.
      Parameters:
      v - value to test
      range - optional two-element output array receiving the containing range
      Returns:
      true if the value is inside a stored range
    • toString

      public String toString()
      Overrides:
      toString in class Object