|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectAbstractCollection<E>
AbstractSet<Range<T>>
RangeSet<T>
T
- The type of range elements.public class RangeSet<T extends Comparable<? super T>>
An ordered set of ranges. RangeSet
objects store an arbitrary number of
ranges in any Java's primitives (int
, float
,
etc.) or any comparable 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(org.geotools.util.Range>)
.
Consequently, ranges returned by 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.
Constructor Summary | |
---|---|
RangeSet(Class<T> type)
Constructs an empty set of range. |
Method Summary | ||
---|---|---|
boolean |
add(byte lower,
byte upper)
Add a range of values to this set. |
|
|
add(Comparable<? super N> min,
Comparable<? super N> max)
Adds a range of values to this set. |
|
boolean |
add(double lower,
double upper)
Add a range of values to this set. |
|
boolean |
add(float lower,
float upper)
Add a range of values to this set. |
|
boolean |
add(int lower,
int upper)
Add a range of values to this set. |
|
boolean |
add(long lower,
long upper)
Add a range of values to this set. |
|
boolean |
add(Range<T> range)
Add a range to this set. |
|
boolean |
add(short lower,
short upper)
Add a range of values to this set. |
|
void |
clear()
Remove all elements from this set of ranges. |
|
RangeSet |
clone()
Returns a clone of this range set. |
|
Comparator<Range<T>> |
comparator()
Returns the comparator associated with this sorted set. |
|
boolean |
contains(Object object)
Returns true if this set contains the specified element. |
|
boolean |
equals(Object object)
Compares the specified object with this set of ranges for equality. |
|
Range<T> |
first()
Returns the first (lowest) range currently in this sorted set. |
|
double |
getMaxValueAsDouble(int index)
Returns a range's maximum value as a double . |
|
double |
getMinValueAsDouble(int index)
Returns a range's minimum value as a double . |
|
int |
hashCode()
Returns a hash value for this set of ranges. |
|
SortedSet<Range<T>> |
headSet(Range<T> upper)
Returns a view of the portion of this sorted set whose elements are strictly less than upper . |
|
int |
indexOfRange(Comparable value)
If the specified value is inside a range, returns the index of this range. |
|
Iterator<Range<T>> |
iterator()
Returns an iterator over the elements in this set of ranges. |
|
Range<T> |
last()
Returns the last (highest) range currently in this sorted set. |
|
boolean |
remove(byte lower,
byte upper)
Remove a range of values from this set. |
|
|
remove(Comparable<? super N> min,
Comparable<? super N> max)
Remove a range of values from this set. |
|
boolean |
remove(double lower,
double upper)
Remove a range of values from this set. |
|
boolean |
remove(float lower,
float upper)
Remove a range of values from this set. |
|
boolean |
remove(int lower,
int upper)
Remove a range of values from this set. |
|
boolean |
remove(long lower,
long upper)
Remove a range of values from this set. |
|
boolean |
remove(short lower,
short upper)
Remove a range of values from this set. |
|
int |
size()
Returns the number of ranges in this set. |
|
SortedSet<Range<T>> |
subSet(Range<T> lower,
Range<T> upper)
Returns a view of the portion of this sorted set whose elements range from lower , inclusive, to upper , exclusive. |
|
SortedSet<Range<T>> |
tailSet(Range<T> lower)
Returns a view of the portion of this sorted set whose elements are greater than or equal to lower . |
|
String |
toString()
Returns a string representation of this set of ranges. |
Methods inherited from class AbstractSet |
---|
removeAll |
Methods inherited from class AbstractCollection |
---|
addAll, containsAll, isEmpty, remove, retainAll, toArray, toArray |
Methods inherited from class Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface Set |
---|
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public RangeSet(Class<T> type) throws IllegalArgumentException
type
- The class of the range elements. It must be a primitive
type or a class implementing Comparable
.
IllegalArgumentException
- if type
is not a
primitive type or a class implementing Comparable
.Method Detail |
---|
public Comparator<Range<T>> comparator()
comparator
in interface SortedSet<Range<T extends Comparable<? super T>>>
public void clear()
clear
in interface Collection<Range<T extends Comparable<? super T>>>
clear
in interface Set<Range<T extends Comparable<? super T>>>
clear
in class AbstractCollection<Range<T extends Comparable<? super T>>>
public int size()
size
in interface Collection<Range<T extends Comparable<? super T>>>
size
in interface Set<Range<T extends Comparable<? super T>>>
size
in class AbstractCollection<Range<T extends Comparable<? super T>>>
public boolean add(Range<T> range)
Range.union(org.geotools.util.Range>)
.
Note: current version do not support open interval (i.e. Range.is[Min/Max]Included()
must return true
).
add
in interface Collection<Range<T extends Comparable<? super T>>>
add
in interface Set<Range<T extends Comparable<? super T>>>
add
in class AbstractCollection<Range<T extends Comparable<? super T>>>
range
- The range to add.
true
if this set changed as a result of the call.public <N> boolean add(Comparable<? super N> min, Comparable<? super N> max) throws IllegalArgumentException
min
- The lower value, inclusive.max
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean add(byte lower, byte upper) throws IllegalArgumentException
lower
- The lower value, inclusive.upper
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean add(short lower, short upper) throws IllegalArgumentException
lower
- The lower value, inclusive.upper
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean add(int lower, int upper) throws IllegalArgumentException
lower
- The lower value, inclusive.upper
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean add(long lower, long upper) throws IllegalArgumentException
lower
- The lower value, inclusive.upper
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean add(float lower, float upper) throws IllegalArgumentException
lower
- The lower value, inclusive.upper
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean add(double lower, double upper) throws IllegalArgumentException
lower
- The lower value, inclusive.upper
- The upper value, inclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public <N> boolean remove(Comparable<? super N> min, Comparable<? super N> max) throws IllegalArgumentException
min
- The lower value to remove, exclusive.max
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean remove(byte lower, byte upper) throws IllegalArgumentException
lower
- The lower value to remove, exclusive.upper
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean remove(short lower, short upper) throws IllegalArgumentException
lower
- The lower value to remove, exclusive.upper
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean remove(int lower, int upper) throws IllegalArgumentException
lower
- The lower value to remove, exclusive.upper
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean remove(long lower, long upper) throws IllegalArgumentException
lower
- The lower value to remove, exclusive.upper
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean remove(float lower, float upper) throws IllegalArgumentException
lower
- The lower value to remove, exclusive.upper
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public boolean remove(double lower, double upper) throws IllegalArgumentException
lower
- The lower value to remove, exclusive.upper
- The upper value to remove, exclusive.
true
if this set changed as a result of the call.
IllegalArgumentException
- if lower
is greater than upper
.public final double getMinValueAsDouble(int index) throws IndexOutOfBoundsException, ClassCastException
double
.
The index
can be any value from 0 inclusive to the set's size
exclusive. The returned values always increase with index
.
index
- The range index, from 0 inclusive to size
exclusive.
IndexOutOfBoundsException
- if index
is out of bounds.
ClassCastException
- if range elements are not convertible to numbers.public final double getMaxValueAsDouble(int index) throws IndexOutOfBoundsException, ClassCastException
double
.
The index
can be any value from 0 inclusive to the set's size
exclusive. The returned values always increase with index
.
index
- The range index, from 0 inclusive to size
exclusive.
IndexOutOfBoundsException
- if index
is out of bounds.
ClassCastException
- if range elements are not convertible to numbers.public int indexOfRange(Comparable value)
-1
.
value
- The value to search.
public boolean contains(Object object)
true
if this set contains the specified element.
contains
in interface Collection<Range<T extends Comparable<? super T>>>
contains
in interface Set<Range<T extends Comparable<? super T>>>
contains
in class AbstractCollection<Range<T extends Comparable<? super T>>>
object
- The object to compare to this set.
true
if the given object is equals to this set.public Range<T> first() throws NoSuchElementException
first
in interface SortedSet<Range<T extends Comparable<? super T>>>
NoSuchElementException
- if the set is empty.public Range<T> last() throws NoSuchElementException
last
in interface SortedSet<Range<T extends Comparable<? super T>>>
NoSuchElementException
- if the set is empty.public SortedSet<Range<T>> subSet(Range<T> lower, Range<T> upper)
lower
, inclusive, to upper
, exclusive.
subSet
in interface SortedSet<Range<T extends Comparable<? super T>>>
lower
- Low endpoint (inclusive) of the sub set.upper
- High endpoint (exclusive) of the sub set.
public SortedSet<Range<T>> headSet(Range<T> upper)
upper
.
headSet
in interface SortedSet<Range<T extends Comparable<? super T>>>
upper
- High endpoint (exclusive) of the headSet.
public SortedSet<Range<T>> tailSet(Range<T> lower)
lower
.
tailSet
in interface SortedSet<Range<T extends Comparable<? super T>>>
lower
- Low endpoint (inclusive) of the tailSet.
public Iterator<Range<T>> iterator()
Range
objects.
iterator
in interface Iterable<Range<T extends Comparable<? super T>>>
iterator
in interface Collection<Range<T extends Comparable<? super T>>>
iterator
in interface Set<Range<T extends Comparable<? super T>>>
iterator
in class AbstractCollection<Range<T extends Comparable<? super T>>>
public int hashCode()
hashCode
in interface Collection<Range<T extends Comparable<? super T>>>
hashCode
in interface Set<Range<T extends Comparable<? super T>>>
hashCode
in class AbstractSet<Range<T extends Comparable<? super T>>>
public boolean equals(Object object)
equals
in interface Collection<Range<T extends Comparable<? super T>>>
equals
in interface Set<Range<T extends Comparable<? super T>>>
equals
in class AbstractSet<Range<T extends Comparable<? super T>>>
object
- The object to compare with this range.
true
if the given object is equals to this range.public RangeSet clone()
clone
in class Object
public String toString()
toString
in class AbstractCollection<Range<T extends Comparable<? super T>>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |