| java.util.AbstractSet org.geotools.util.RangeSet
RangeSet | public class RangeSet extends AbstractSet implements SortedSet,Cloneable,Serializable(Code) | | An ordered set of ranges.
RangeSet objects store an arbitrary number of
in any Java's primitives (
int ,
float ,
etc.) or any
objects. Ranges may be added in any order.
When a range is added,
RangeSet first looks for an existing range overlapping the
specified range. If an overlapping range is found, ranges are merged as of
Range.union .
Consequently, ranges returned by
RangeSet.iterator may not be the same than added ranges.
All entries in this set can be seen as
Range objects.
This class is not thread-safe.
since: 2.0 version: $Id: RangeSet.java 22443 2006-10-27 20:47:22Z desruisseaux $ author: Martin Desruisseaux author: Andrea Aime |
Constructor Summary | |
public | RangeSet(Class type) Construct an empty set of range.
Parameters: type - The class of the range elements. |
Method Summary | |
public boolean | add(Object r) Add a range to this set. | public boolean | add(Comparable lower, Comparable upper) Add a range of values to this set. | public boolean | add(byte lower, byte upper) Add a range of values to this set. | public boolean | add(short lower, short upper) Add a range of values to this set. | public boolean | add(int lower, int upper) Add a range of values to this set. | public boolean | add(long lower, long upper) Add a range of values to this set. | public boolean | add(float lower, float upper) Add a range of values to this set. | public boolean | add(double lower, double upper) Add a range of values to this set. | public void | clear() Remove all elements from this set of ranges. | public Object | clone() Returns a clone of this range set. | public Comparator | comparator() Returns the comparator associated with this sorted set. | public boolean | contains(Object object) Returns
true if this set contains the specified element. | public boolean | equals(Object object) Compares the specified object with
this set of ranges for equality. | public Object | first() Returns the first (lowest) range currently in this sorted set. | final public double | getMaxValueAsDouble(int index) Returns a
as a
double .
The
index can be any value from 0 inclusive to the set's
RangeSet.size size exclusive. | final public double | getMinValueAsDouble(int index) Returns a
as a
double .
The
index can be any value from 0 inclusive to the set's
RangeSet.size size exclusive. | public int | hashCode() Returns a hash value for this set of ranges. | public SortedSet | headSet(Object upper) Returns a view of the portion of this sorted set whose elements are
strictly less than
upper .
Parameters: upper - High endpoint (exclusive) of the headSet. | public int | indexOfRange(Comparable value) If the specified value is inside a range, returns the index of this range.
Otherwise, returns
-1 .
Parameters: value - The value to search. | public java.util.Iterator | iterator() Returns an iterator over the elements in this set of ranges. | public Object | last() Returns the last (highest) range currently in this sorted set. | public boolean | remove(Comparable lower, Comparable upper) Remove a range of values from this set. | public boolean | remove(byte lower, byte upper) Remove a range of values from this set. | public boolean | remove(short lower, short upper) Remove a range of values from this set. | public boolean | remove(int lower, int upper) Remove a range of values from this set. | public boolean | remove(long lower, long upper) Remove a range of values from this set. | public boolean | remove(float lower, float upper) Remove a range of values from this set. | public boolean | remove(double lower, double upper) Remove a range of values from this set. | public int | size() Returns the number of ranges in this set. | public SortedSet | subSet(Object lower, Object upper) Returns a view of the portion of this sorted set whose elements range
from
lower , inclusive, to
upper , exclusive.
Parameters: lower - Low endpoint (inclusive) of the sub set. Parameters: upper - High endpoint (exclusive) of the sub set. | public SortedSet | tailSet(Object lower) Returns a view of the portion of this sorted set whose elements are
greater than or equal to
lower .
Parameters: lower - Low endpoint (inclusive) of the tailSet. | public String | toString() Returns a string representation of this set of ranges. |
add | public boolean add(Object r) throws ClassCastException(Code) | | Add a range to this set. Range may be added in any order.
If the specified range overlap an existing range, the two
range will be merged as of
Range.union .
Note: current version do not support open interval (i.e.
Range.is[Min/Max]Included() must return
true ). It may be fixed in a future version.
Parameters: r - The range to add. The RangeSet classwill never modify the supplied Range object. true if this set changed as a result of the call. throws: ClassCastException - if the argument is not a Range object. |
add | public boolean add(Comparable lower, Comparable upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
add | public boolean add(byte lower, byte upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
add | public boolean add(short lower, short upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
add | public boolean add(int lower, int upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
add | public boolean add(long lower, long upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
add | public boolean add(float lower, float upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
add | public boolean add(double lower, double upper) throws IllegalArgumentException(Code) | | Add a range of values to this set. Range may be added in any order.
If the specified range overlap an existing range, the two ranges
will be merged.
Parameters: lower - The lower value, inclusive. Parameters: upper - The upper value, inclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
clear | public void clear()(Code) | | Remove all elements from this set of ranges.
|
clone | public Object clone()(Code) | | Returns a clone of this range set.
|
comparator | public Comparator comparator()(Code) | | Returns the comparator associated with this sorted set.
|
contains | public boolean contains(Object object)(Code) | | Returns
true if this set contains the specified element.
|
equals | public boolean equals(Object object)(Code) | | Compares the specified object with
this set of ranges for equality.
|
hashCode | public int hashCode()(Code) | | Returns a hash value for this set of ranges.
This value need not remain consistent between
different implementations of the same class.
|
headSet | public SortedSet headSet(Object upper)(Code) | | Returns a view of the portion of this sorted set whose elements are
strictly less than
upper .
Parameters: upper - High endpoint (exclusive) of the headSet. A view of the specified initial range of this sorted set. |
indexOfRange | public int indexOfRange(Comparable value)(Code) | | If the specified value is inside a range, returns the index of this range.
Otherwise, returns
-1 .
Parameters: value - The value to search. The index of the range which contains this value, or -1 if there is no such range. |
iterator | public java.util.Iterator iterator()(Code) | | Returns an iterator over the elements in this set of ranges.
All elements are
Range objects.
|
remove | public boolean remove(Comparable lower, Comparable upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
remove | public boolean remove(byte lower, byte upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
remove | public boolean remove(short lower, short upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
remove | public boolean remove(int lower, int upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
remove | public boolean remove(long lower, long upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
remove | public boolean remove(float lower, float upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
remove | public boolean remove(double lower, double upper) throws IllegalArgumentException(Code) | | Remove a range of values from this set. Range may be removed in any order.
Parameters: lower - The lower value to remove, exclusive. Parameters: upper - The upper value to remove, exclusive. true if this set changed as a result of the call. throws: IllegalArgumentException - if lower is greater than upper . |
size | public int size()(Code) | | Returns the number of ranges in this set.
|
subSet | public SortedSet subSet(Object lower, Object upper)(Code) | | Returns a view of the portion of this sorted set whose elements range
from
lower , inclusive, to
upper , exclusive.
Parameters: lower - Low endpoint (inclusive) of the sub set. Parameters: upper - High endpoint (exclusive) of the sub set. A view of the specified range within this sorted set. |
tailSet | public SortedSet tailSet(Object lower)(Code) | | Returns a view of the portion of this sorted set whose elements are
greater than or equal to
lower .
Parameters: lower - Low endpoint (inclusive) of the tailSet. A view of the specified final range of this sorted set. |
toString | public String toString()(Code) | | Returns a string representation of this set of ranges.
The returned string is implementation dependent.
It is usually provided for debugging purposes.
|
|
|