Package org.apache.sis.util.collection
Class RangeSet.SubSet
- All Implemented Interfaces:
Serializable
,Iterable<Range<E>>
,Collection<Range<E>>
,Set<Range<E>>
,SortedSet<Range<E>>
- Enclosing class:
- RangeSet<E extends Comparable<? super E>>
private final class RangeSet.SubSet
extends AbstractSet<Range<E>>
implements SortedSet<Range<E>>, Serializable
A view over a subset of
RangeSet
.
Instances of this class are created by the RangeSet.intersect(Range)
method.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Index ofsubRange
minimum and maximum values in the array of the enclosingRangeSet
.private int
Modification count of the enclosingRangeSet
, used for detecting changes.private static final long
For cross-version compatibility.The minimal and maximal values of this subset,private int
Index ofsubRange
minimum and maximum values in the array of the enclosingRangeSet
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a new range in the enclosingRangeSet
, and updates this subset in order to contain that range.void
clear()
Clears this subset by removing all elements in the range given to the constructor.Comparator<Range<E>>
Returns the comparator, which is the same than the enclosing class.boolean
Tests if this subset contains the given range.first()
Returns the first range in this subset, intersected with the range given to the constructor.Delegates subset creation to the enclosing class.iterator()
Returns an iterator over the elements in this subset.last()
Returns the last range in this subset, intersected with the range given to the constructor.boolean
Removes the given range or part of it from the enclosingRangeSet
.int
size()
Returns the number of ranges in this subset.Delegates subset creation to the enclosing class.Delegates subset creation to the enclosing class.private void
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
Methods inherited from interface java.util.SortedSet
spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
subRange
The minimal and maximal values of this subset, -
lower
private transient int lowerIndex ofsubRange
minimum and maximum values in the array of the enclosingRangeSet
. Those indices need to be recomputed every time the enclosingRangeSet
has been modified.- See Also:
-
upper
private transient int upperIndex ofsubRange
minimum and maximum values in the array of the enclosingRangeSet
. Those indices need to be recomputed every time the enclosingRangeSet
has been modified.- See Also:
-
modCount
private transient int modCountModification count of the enclosingRangeSet
, used for detecting changes.
-
-
Constructor Details
-
SubSet
Creates a new subset of the enclosingRangeSet
between the given values.- Parameters:
subRange
- the range to intersect with the enclosingRangeSet
.
-
-
Method Details
-
updateBounds
private void updateBounds() -
comparator
Returns the comparator, which is the same than the enclosing class.- Specified by:
comparator
in interfaceSortedSet<Range<E extends Comparable<? super E>>>
-
clear
public void clear()Clears this subset by removing all elements in the range given to the constructor.- Specified by:
clear
in interfaceCollection<Range<E extends Comparable<? super E>>>
- Specified by:
clear
in interfaceSet<Range<E extends Comparable<? super E>>>
- Overrides:
clear
in classAbstractCollection<Range<E extends Comparable<? super E>>>
-
size
public int size()Returns the number of ranges in this subset.- Specified by:
size
in interfaceCollection<Range<E extends Comparable<? super E>>>
- Specified by:
size
in interfaceSet<Range<E extends Comparable<? super E>>>
- Specified by:
size
in classAbstractCollection<Range<E extends Comparable<? super E>>>
-
add
Adds a new range in the enclosingRangeSet
, and updates this subset in order to contain that range.- Specified by:
add
in interfaceCollection<Range<E extends Comparable<? super E>>>
- Specified by:
add
in interfaceSet<Range<E extends Comparable<? super E>>>
- Overrides:
add
in classAbstractCollection<Range<E extends Comparable<? super E>>>
-
remove
Removes the given range or part of it from the enclosingRangeSet
. Before to perform the removal, this method intersects the given range with the range of this subset.- Specified by:
remove
in interfaceCollection<Range<E extends Comparable<? super E>>>
- Specified by:
remove
in interfaceSet<Range<E extends Comparable<? super E>>>
- Overrides:
remove
in classAbstractCollection<Range<E extends Comparable<? super E>>>
-
contains
Tests if this subset contains the given range. Before to delegates to the enclosing class, this method filter-out the ranges that are not contained in the range given to the constructor of this subset.- Specified by:
contains
in interfaceCollection<Range<E extends Comparable<? super E>>>
- Specified by:
contains
in interfaceSet<Range<E extends Comparable<? super E>>>
- Overrides:
contains
in classAbstractCollection<Range<E extends Comparable<? super E>>>
-
first
Returns the first range in this subset, intersected with the range given to the constructor. -
last
Returns the last range in this subset, intersected with the range given to the constructor. -
subSet
Delegates subset creation to the enclosing class. The new subset will not be bigger than this subset. -
headSet
Delegates subset creation to the enclosing class. The new subset will not be bigger than this subset. -
tailSet
Delegates subset creation to the enclosing class. The new subset will not be bigger than this subset. -
iterator
Returns an iterator over the elements in this subset.- Specified by:
iterator
in interfaceCollection<Range<E extends Comparable<? super E>>>
- Specified by:
iterator
in interfaceIterable<Range<E extends Comparable<? super E>>>
- Specified by:
iterator
in interfaceSet<Range<E extends Comparable<? super E>>>
- Specified by:
iterator
in classAbstractCollection<Range<E extends Comparable<? super E>>>
-