org.geotoolkit.util.collection
Class RangeSet<T extends Comparable<? super T>>

Object
  extended by AbstractCollection<E>
      extended by AbstractSet<Range<T>>
          extended by RangeSet<T>
Type Parameters:
T - The type of range elements.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Range<T>>, Collection<Range<T>>, Set<Range<T>>, SortedSet<Range<T>>, CheckedCollection<Range<T>>, CheckedContainer<Range<T>>

Deprecated. Replaced by Apache SIS RangeSet.

@Deprecated
public class RangeSet<T extends Comparable<? super T>>
extends AbstractSet<Range<T>>
implements CheckedCollection<Range<T>>, SortedSet<Range<T>>, Cloneable, Serializable

An ordered set of ranges. RangeSet objects store an arbitrary number of ranges in any Java primitives (int, float, etc.) or any comparable objects.

Ranges can 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(Range). Consequently, ranges returned by iterator() may not be the same than added ranges.

Since:
2.0
Version:
3.00
Author:
Martin Desruisseaux (IRD), Andrea Aime (TOPP)
See Also:
Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Constructor Summary
RangeSet(Class<T> type)
          Deprecated. Constructs an empty set of range.
 
Method Summary
 boolean add(byte min, byte max)
          Deprecated. Adds a range of values to this set.
 boolean add(double min, double max)
          Deprecated. Adds a range of values to this set.
 boolean add(float min, float max)
          Deprecated. Adds a range of values to this set.
 boolean add(int min, int max)
          Deprecated. Adds a range of values to this set.
 boolean add(long min, long max)
          Deprecated. Adds a range of values to this set.
 boolean add(Range<T> range)
          Deprecated. Adds a range to this set.
 boolean add(short min, short max)
          Deprecated. Adds a range of values to this set.
 boolean add(T min, T max)
          Deprecated. Adds a range of values to this set.
 void clear()
          Deprecated. Remove all elements from this set of ranges.
 RangeSet<T> clone()
          Deprecated. Returns a clone of this range set.
 Comparator<Range<T>> comparator()
          Deprecated. Returns the comparator associated with this sorted set.
 boolean contains(Object object)
          Deprecated. Returns true if this set contains the specified element.
 boolean equals(Object object)
          Deprecated. Compares the specified object with this set of ranges for equality.
 Range<T> first()
          Deprecated. Returns the first (lowest) range currently in this sorted set.
 Class<? extends Range<T>> getElementType()
          Deprecated. Returns the type of elements in this collection.
 double getMaxValueAsDouble(int index)
          Deprecated. Returns a range's maximum value as a double.
 double getMinValueAsDouble(int index)
          Deprecated. Returns a range's minimum value as a double.
 int hashCode()
          Deprecated. Returns a hash value for this set of ranges.
 SortedSet<Range<T>> headSet(Range<T> upper)
          Deprecated. Returns a view of the portion of this sorted set whose elements are strictly less than upper.
 int indexOfRange(Comparable<?> value)
          Deprecated. If the specified value is inside a range, returns the index of this range.
 Iterator<Range<T>> iterator()
          Deprecated. Returns an iterator over the elements in this set of ranges.
 Range<T> last()
          Deprecated. Returns the last (highest) range currently in this sorted set.
 boolean remove(byte min, byte max)
          Deprecated. Removes a range of values from this set.
 boolean remove(double min, double max)
          Deprecated. Removes a range of values from this set.
 boolean remove(float min, float max)
          Deprecated. Removes a range of values from this set.
 boolean remove(int min, int max)
          Deprecated. Removes a range of values from this set.
 boolean remove(long min, long max)
          Deprecated. Removes a range of values from this set.
 boolean remove(Object object)
          Deprecated. Removes a range to this set.
 boolean remove(short min, short max)
          Deprecated. Removes a range of values from this set.
 boolean remove(T min, T max)
          Deprecated. Removes a range of values from this set.
 int size()
          Deprecated. Returns the number of ranges in this set.
 SortedSet<Range<T>> subSet(Range<T> lower, Range<T> upper)
          Deprecated. 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)
          Deprecated. Returns a view of the portion of this sorted set whose elements are greater than or equal to lower.
 String toString()
          Deprecated. Returns a string representation of this set of ranges.
 void trimToSize()
          Deprecated. Trims this set to the minimal amount of memory required for holding its data.
 
Methods inherited from class AbstractSet
removeAll
 
Methods inherited from class AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Set
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

RangeSet

public RangeSet(Class<T> type)
Deprecated. 
Constructs an empty set of range.

Parameters:
type - The class of the range elements.
Method Detail

getElementType

public Class<? extends Range<T>> getElementType()
Deprecated. 
Returns the type of elements in this collection. This is typically the NumberRange or DateRange class, or failing that the plain Range class.

Specified by:
getElementType in interface CheckedCollection<Range<T extends Comparable<? super T>>>
Specified by:
getElementType in interface CheckedContainer<Range<T extends Comparable<? super T>>>
Returns:
The element type.
Since:
3.00

comparator

public Comparator<Range<T>> comparator()
Deprecated. 
Returns the comparator associated with this sorted set.

Specified by:
comparator in interface SortedSet<Range<T extends Comparable<? super T>>>

clear

public void clear()
Deprecated. 
Remove all elements from this set of ranges.

Specified by:
clear in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
clear in interface Set<Range<T extends Comparable<? super T>>>
Overrides:
clear in class AbstractCollection<Range<T extends Comparable<? super T>>>

size

public int size()
Deprecated. 
Returns the number of ranges in this set.

Specified by:
size in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
size in interface Set<Range<T extends Comparable<? super T>>>
Specified by:
size in class AbstractCollection<Range<T extends Comparable<? super T>>>

add

public boolean add(Range<T> range)
Deprecated. 
Adds a range to this set. Ranges may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged as of Range.union(Range).

Note: current version do not support open intervals (i.e. Range.is[Min/Max]Included() must return true).

Specified by:
add in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
add in interface Set<Range<T extends Comparable<? super T>>>
Overrides:
add in class AbstractCollection<Range<T extends Comparable<? super T>>>
Parameters:
range - The range to add.
Returns:
true if this set changed as a result of the call.
TODO:
Support open intervals.

add

public boolean add(T min,
                   T max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Ranges may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

add

public boolean add(byte min,
                   byte max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Range may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

add

public boolean add(short min,
                   short max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Range may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

add

public boolean add(int min,
                   int max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Range may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

add

public boolean add(long min,
                   long max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Range may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

add

public boolean add(float min,
                   float max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Range may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

add

public boolean add(double min,
                   double max)
            throws IllegalArgumentException
Deprecated. 
Adds a range of values to this set. Range may be added in any order. If the specified range overlaps an existing range, the two ranges will be merged.

Parameters:
min - The lower value, inclusive.
max - The upper value, inclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(Object object)
Deprecated. 
Removes a range to this set.

Note: current version do not support closed intervals (i.e. Range.is[Min/Max]Included() must return false).

Specified by:
remove in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
remove in interface Set<Range<T extends Comparable<? super T>>>
Overrides:
remove in class AbstractCollection<Range<T extends Comparable<? super T>>>
Parameters:
object - The range to remove.
Returns:
true if this set changed as a result of the call.
TODO:
Support closed intervals.

remove

public boolean remove(T min,
                      T max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(byte min,
                      byte max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(short min,
                      short max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(int min,
                      int max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(long min,
                      long max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(float min,
                      float max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

remove

public boolean remove(double min,
                      double max)
               throws IllegalArgumentException
Deprecated. 
Removes a range of values from this set. Range may be removed in any order.

Parameters:
min - The lower value to remove, exclusive.
max - The upper value to remove, exclusive.
Returns:
true if this set changed as a result of the call.
Throws:
IllegalArgumentException - if lower is greater than upper.

getMinValueAsDouble

public final double getMinValueAsDouble(int index)
                                 throws IndexOutOfBoundsException,
                                        ClassCastException
Deprecated. 
Returns a range's minimum value as a double. The index can be any value from 0 inclusive to the set's size exclusive. The returned values always increase with index.

Parameters:
index - The range index, from 0 inclusive to size exclusive.
Returns:
The minimum value for the range at the specified index.
Throws:
IndexOutOfBoundsException - if index is out of bounds.
ClassCastException - if range elements are not convertible to numbers.

getMaxValueAsDouble

public final double getMaxValueAsDouble(int index)
                                 throws IndexOutOfBoundsException,
                                        ClassCastException
Deprecated. 
Returns a range's maximum value as a double. The index can be any value from 0 inclusive to the set's size exclusive. The returned values always increase with index.

Parameters:
index - The range index, from 0 inclusive to size exclusive.
Returns:
The maximum value for the range at the specified index.
Throws:
IndexOutOfBoundsException - if index is out of bounds.
ClassCastException - if range elements are not convertible to numbers.

indexOfRange

public int indexOfRange(Comparable<?> value)
Deprecated. 
If the specified value is inside a range, returns the index of this range. Otherwise, returns -1.

Parameters:
value - The value to search.
Returns:
The index of the range which contains this value, or -1 if there is no such range.

contains

public boolean contains(Object object)
Deprecated. 
Returns true if this set contains the specified element.

Specified by:
contains in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
contains in interface Set<Range<T extends Comparable<? super T>>>
Overrides:
contains in class AbstractCollection<Range<T extends Comparable<? super T>>>
Parameters:
object - The object to compare to this set.
Returns:
true if the given object is equal to this set.

first

public Range<T> first()
                                             throws NoSuchElementException
Deprecated. 
Returns the first (lowest) range currently in this sorted set.

Specified by:
first in interface SortedSet<Range<T extends Comparable<? super T>>>
Throws:
NoSuchElementException - if the set is empty.

last

public Range<T> last()
                                            throws NoSuchElementException
Deprecated. 
Returns the last (highest) range currently in this sorted set.

Specified by:
last in interface SortedSet<Range<T extends Comparable<? super T>>>
Throws:
NoSuchElementException - if the set is empty.

subSet

public SortedSet<Range<T>> subSet(Range<T> lower,
                                  Range<T> upper)
Deprecated. 
Returns a view of the portion of this sorted set whose elements range from lower, inclusive, to upper, exclusive.

Specified by:
subSet in interface SortedSet<Range<T extends Comparable<? super T>>>
Parameters:
lower - Low endpoint (inclusive) of the sub set.
upper - High endpoint (exclusive) of the sub set.
Returns:
A view of the specified range within this sorted set.

headSet

public SortedSet<Range<T>> headSet(Range<T> upper)
Deprecated. 
Returns a view of the portion of this sorted set whose elements are strictly less than upper.

Specified by:
headSet in interface SortedSet<Range<T extends Comparable<? super T>>>
Parameters:
upper - High endpoint (exclusive) of the headSet.
Returns:
A view of the specified initial range of this sorted set.

tailSet

public SortedSet<Range<T>> tailSet(Range<T> lower)
Deprecated. 
Returns a view of the portion of this sorted set whose elements are greater than or equal to lower.

Specified by:
tailSet in interface SortedSet<Range<T extends Comparable<? super T>>>
Parameters:
lower - Low endpoint (inclusive) of the tailSet.
Returns:
A view of the specified final range of this sorted set.

iterator

public Iterator<Range<T>> iterator()
Deprecated. 
Returns an iterator over the elements in this set of ranges. All elements are Range objects.

Specified by:
iterator in interface Iterable<Range<T extends Comparable<? super T>>>
Specified by:
iterator in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
iterator in interface Set<Range<T extends Comparable<? super T>>>
Specified by:
iterator in class AbstractCollection<Range<T extends Comparable<? super T>>>

trimToSize

public final void trimToSize()
Deprecated. 
Trims this set to the minimal amount of memory required for holding its data. This method may be invoked after a set construction is completed in order to free unused memory.

Since:
3.00

hashCode

public int hashCode()
Deprecated. 
Returns a hash value for this set of ranges. This value need not remain consistent between different implementations of the same class.

Specified by:
hashCode in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
hashCode in interface Set<Range<T extends Comparable<? super T>>>
Overrides:
hashCode in class AbstractSet<Range<T extends Comparable<? super T>>>

equals

public boolean equals(Object object)
Deprecated. 
Compares the specified object with this set of ranges for equality.

Specified by:
equals in interface Collection<Range<T extends Comparable<? super T>>>
Specified by:
equals in interface Set<Range<T extends Comparable<? super T>>>
Overrides:
equals in class AbstractSet<Range<T extends Comparable<? super T>>>
Parameters:
object - The object to compare with this range.
Returns:
true if the given object is equal to this range.

clone

public RangeSet<T> clone()
Deprecated. 
Returns a clone of this range set.

Overrides:
clone in class Object
Returns:
A clone of this range set.
See Also:
Object.clone()

toString

public String toString()
Deprecated. 
Returns a string representation of this set of ranges. The returned string is implementation dependent and should be used for debugging purposes only.

Overrides:
toString in class AbstractCollection<Range<T extends Comparable<? super T>>>


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.