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 intIndex ofsubRangeminimum and maximum values in the array of the enclosingRangeSet.private intModification count of the enclosingRangeSet, used for detecting changes.private static final longFor cross-version compatibility.The minimal and maximal values of this subset,private intIndex ofsubRangeminimum and maximum values in the array of the enclosingRangeSet. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a new range in the enclosingRangeSet, and updates this subset in order to contain that range.voidclear()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.booleanTests 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.booleanRemoves the given range or part of it from the enclosingRangeSet.intsize()Returns the number of ranges in this subset.Delegates subset creation to the enclosing class.Delegates subset creation to the enclosing class.private voidMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArrayMethods 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 ofsubRangeminimum and maximum values in the array of the enclosingRangeSet. Those indices need to be recomputed every time the enclosingRangeSethas been modified.- See Also:
-
upper
private transient int upperIndex ofsubRangeminimum and maximum values in the array of the enclosingRangeSet. Those indices need to be recomputed every time the enclosingRangeSethas 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 enclosingRangeSetbetween 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:
comparatorin 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:
clearin interfaceCollection<Range<E extends Comparable<? super E>>>- Specified by:
clearin interfaceSet<Range<E extends Comparable<? super E>>>- Overrides:
clearin classAbstractCollection<Range<E extends Comparable<? super E>>>
-
size
public int size()Returns the number of ranges in this subset.- Specified by:
sizein interfaceCollection<Range<E extends Comparable<? super E>>>- Specified by:
sizein interfaceSet<Range<E extends Comparable<? super E>>>- Specified by:
sizein 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:
addin interfaceCollection<Range<E extends Comparable<? super E>>>- Specified by:
addin interfaceSet<Range<E extends Comparable<? super E>>>- Overrides:
addin 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:
removein interfaceCollection<Range<E extends Comparable<? super E>>>- Specified by:
removein interfaceSet<Range<E extends Comparable<? super E>>>- Overrides:
removein 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:
containsin interfaceCollection<Range<E extends Comparable<? super E>>>- Specified by:
containsin interfaceSet<Range<E extends Comparable<? super E>>>- Overrides:
containsin 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:
iteratorin interfaceCollection<Range<E extends Comparable<? super E>>>- Specified by:
iteratorin interfaceIterable<Range<E extends Comparable<? super E>>>- Specified by:
iteratorin interfaceSet<Range<E extends Comparable<? super E>>>- Specified by:
iteratorin classAbstractCollection<Range<E extends Comparable<? super E>>>
-