All Packages Class Hierarchy This Package Previous Next Index
Class net.strandberg.util.IntIntervalSet
java.lang.Object
|
+----net.strandberg.util.IntIntervalSet
- public class IntIntervalSet
- extends Object
Class IntIntervalSet represents a set of intervals.
- Version:
- $Revision: 0.0 $
- Author:
- Mats Strandberg
-
IntIntervalSet()
- Constructs an "empty" IntIntervalSet.
-
add(int, int)
- Adds an IntInterval to this set.
-
add(IntInterval)
- Adds an IntInterval to this set.
-
create(String)
- Creates an IntIntervalSet by parsing the string given as input.
-
includes(int)
-
Checks if the given integer is inside the interval set.
-
main(String[])
- Tests the class.
-
toString()
- Returns a string representation of the object.
IntIntervalSet
public IntIntervalSet()
- Constructs an "empty" IntIntervalSet.
main
public static void main(String args[])
- Tests the class.
create
public static IntIntervalSet create(String s)
- Creates an IntIntervalSet by parsing the string given as input.
The string should be on the format
integerInterval[,
integerInterval]*
i.e. one or many integer intervals; separated by commas.
The integerInterval is on the form integer or
integer-
integer. Examples
of valid input strings are then:
125
7-125
5,7-125
There's no support for parsing negative values
- Parameters:
- s - the string to be parsed
- Returns:
- an IntIntervalSet or null if the string couldn't be parsed
- See Also:
- IntInterval
add
public void add(IntInterval ii)
- Adds an IntInterval to this set.
- Parameters:
- ii - IntInterval to add
add
public void add(int lower,
int upper)
- Adds an IntInterval to this set.
- Parameters:
- lower - lower limit for the interval (inclusive)
- upper - upper limit for the interval (inclusive)
includes
public boolean includes(int i)
- Checks if the given integer is inside the interval set.
- Parameters:
- i - the integer to check against the interval set
- Returns:
- true if the integer is inside the interval set
toString
public String toString()
- Returns a string representation of the object.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index