Class IntegerRanges
java.lang.Object
com.pnfsoftware.jeb.util.primitives.IntegerRanges
Collection of integer ranges (a range is noted
[beg, end) or [beg, end[).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int beg, int end) Add a non-empty range.intcount()Count the number of stored ranges.booleanisInsideRange(int v, int[] range) Determine whether a value belongs to one of the stored ranges.toString()
-
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 startend- 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 testrange- optional two-element output array receiving the containing range- Returns:
- true if the value is inside a stored range
-
toString
-