Package org.apache.sis.util.collection
Class FrequencySortedSet.SubSet
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.apache.sis.util.collection.FrequencySortedSet.SubSet
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,SequencedCollection<E>
,SequencedSet<E>
,Set<E>
,SortedSet<E>
- Enclosing class:
FrequencySortedSet<E>
private final class FrequencySortedSet.SubSet
extends AbstractSet<E>
implements SortedSet<E>, Serializable
A view over a subset of
FrequencySortedSet
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate E[]
Reference to theFrequencySortedSet.sorted
array, used for detecting changes.private final E
Low endpoint (inclusive) of the subset.private final boolean
Whether the set should take in accountfromElement
ortoElement
.private final boolean
Whether the set should take in accountfromElement
ortoElement
.private int
Lower and upper index computed fromfromElement
andtoElement
.private static final long
For cross-version compatibility.private final E
High endpoint (exclusive) of the subset.private int
Lower and upper index computed fromfromElement
andtoElement
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the comparator, which is the same thanFrequencySortedSet.comparator()
.private void
first()
Returns the first element in this subset.Returns a view of the portion of this subset whose elements occur with a frequency strictly less thantoElement
frequency.iterator()
Returns an iterator over the elements in this subset.last()
Returns the last element in this subset.int
size()
Returns the number of elements in this subset.Returns a view of the portion of this subset whose elements occur with a frequency in the range offromElement
frequency inclusive totoElement
frequency exclusive.Returns a view of the portion of this subset whose elements occur with a frequency equal or greater thanfromElement
frequency.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, 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
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
Methods inherited from interface java.util.SortedSet
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, reversed, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
elements
Reference to theFrequencySortedSet.sorted
array, used for detecting changes. -
fromElement
Low endpoint (inclusive) of the subset. May benull
. -
toElement
High endpoint (exclusive) of the subset. May benull
. -
hasFrom
private final boolean hasFromWhether the set should take in accountfromElement
ortoElement
. We have to use those booleans (we cannot usenull
sentinel value instead) becausenull
is a legal value forfrom/toElement
. -
hasTo
private final boolean hasToWhether the set should take in accountfromElement
ortoElement
. We have to use those booleans (we cannot usenull
sentinel value instead) becausenull
is a legal value forfrom/toElement
. -
lower
private transient int lowerLower and upper index computed fromfromElement
andtoElement
. -
upper
private transient int upperLower and upper index computed fromfromElement
andtoElement
.
-
-
Constructor Details
-
SubSet
Creates a new subset from the lower element (inclusive) to the upper element (exclusive). Each endpoint can be null.
-
-
Method Details
-
comparator
Returns the comparator, which is the same thanFrequencySortedSet.comparator()
.- Specified by:
comparator
in interfaceSortedSet<E>
-
ensureValidRange
private void ensureValidRange() -
iterator
Returns an iterator over the elements in this subset. -
size
public int size()Returns the number of elements in this subset.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
first
Returns the first element in this subset. -
last
Returns the last element in this subset. -
headSet
Returns a view of the portion of this subset whose elements occur with a frequency strictly less thantoElement
frequency. -
tailSet
Returns a view of the portion of this subset whose elements occur with a frequency equal or greater thanfromElement
frequency. -
subSet
Returns a view of the portion of this subset whose elements occur with a frequency in the range offromElement
frequency inclusive totoElement
frequency exclusive. -
subSet
Implementation ofheadSet(Object)
,tailSet(Object)
andsubSet(Object, Object)
. Thebounds
argument tell whichFrequencySortedSet
method to delegate to.
-