Package eu.simuline.util
Interface SortedMultiSet<T>
-
- Type Parameters:
T- the class of the elements of this multi-set. Created: Sun Nov 23 22:36:30 2014
- All Superinterfaces:
java.lang.Iterable<T>,MultiSet<T>
- All Known Implementing Classes:
CollectionsExt.ImmutableSortedMultiSet,TreeMultiSet
public interface SortedMultiSet<T> extends MultiSet<T>
Represents a sorted set with multiplicities. If MultiSet extend Set, SortedMultiSet shall extend SortedSet- Version:
- 1.0
- Author:
- Ernst Reissner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface eu.simuline.util.MultiSet
MultiSet.Multiplicity
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Comparator<? super T>comparator()Returns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.Tfirst()Returns the first (lowest) element currently in this set.java.util.NavigableMap<T,MultiSet.Multiplicity>getMap()Returns a view of the underlying map of thisMultiSetas a map mapping each entry to its multiplicity.java.util.SortedSet<T>getSet()Returns a view of the underlying sorted set of thisSortedMultiSet.SortedMultiSet<T>headSet(T toElement)Returns a view of the portion of this multi-set whose elements are strictly less thantoElement.Tlast()Returns the last (highest) element currently in this set.SortedMultiSet<T>subSet(T fromElement, T toElement)Returns a view of the portion of this multi-set whose elements range fromfromElementinclusively totoElementexclusively.SortedMultiSet<T>tailSet(T fromElement)Returns a view of the portion of this multi-set whose elements are greater than or equal tofromElement.-
Methods inherited from interface eu.simuline.util.MultiSet
add, addAll, addAll, addWithMult, addWithMult, clear, contains, containsAll, equals, getMaxMult, getMultiplicity, getMultiplicityObj, getObjWithMaxMult, getSetWithMults, hashCode, isEmpty, iterator, remove, removeAll, removeWithMult, removeWithMult, retainAll, setMultiplicity, size, sizeWithMult, toArray, toArray, toString
-
-
-
-
Method Detail
-
getSet
java.util.SortedSet<T> getSet()
Returns a view of the underlying sorted set of thisSortedMultiSet. For certain implementations, this set is immutable to prevent implicit modification of thisSortedMultiSet.
-
getMap
java.util.NavigableMap<T,MultiSet.Multiplicity> getMap()
Returns a view of the underlying map of thisMultiSetas a map mapping each entry to its multiplicity.
-
comparator
java.util.Comparator<? super T> comparator()
Returns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.- Returns:
- the comparator used to order the elements in this set,
or
nullif this set uses the natural ordering of its elements.
-
first
T first()
Returns the first (lowest) element currently in this set.- Returns:
- the first (lowest) element currently in this set
- Throws:
java.util.NoSuchElementException- if this set is empty.
-
last
T last()
Returns the last (highest) element currently in this set.- Returns:
- the last (highest) element currently in this set.
- Throws:
java.util.NoSuchElementException- if this set is empty.
-
headSet
SortedMultiSet<T> headSet(T toElement)
Returns a view of the portion of this multi-set whose elements are strictly less thantoElement. The returned multi-set is backed by this multi-set, so changes in the returned set are reflected in this multi-set, and vice-versa. The returned multi-set supports all optional multi-set operations that this multi-set supports.The returned multi-set will throw an
IllegalArgumentExceptionon an attempt to insert an element outside its range.- Parameters:
toElement- high endpoint (exclusive) of the returned multi-set.- Returns:
- a view of the portion of this multi-set
whose elements are strictly less than
toElement. - Throws:
java.lang.ClassCastException- iftoElementis not compatible with this multi-set's comparator (or, if the set has no comparator, iftoElementdoes not implementComparable). Implementations may, but are not required to, throw this exception iftoElementcannot be compared to elements currently in this multi-set.java.lang.NullPointerException- iftoElementisnulland this multi-set does not permitnullelements.java.lang.IllegalArgumentException- if this multi-set itself has a restricted range, andtoElementlies outside the bounds of the range.
-
tailSet
SortedMultiSet<T> tailSet(T fromElement)
Returns a view of the portion of this multi-set whose elements are greater than or equal tofromElement. The returned multi-set is backed by this multi-set, so changes in the returned set are reflected in this multi-set, and vice-versa. The returned multi-set supports all optional multi-set operations that this multi-set supports.The returned multi-set will throw an
IllegalArgumentExceptionon an attempt to insert an element outside its range.- Parameters:
fromElement- low endpoint (inclusive) of the returned multi-set.- Returns:
- a view of the portion of this multi-set
whose elements are greater than or equal to
fromElement. - Throws:
java.lang.ClassCastException- iffromElementis not compatible with this multi-set's comparator (or, if the set has no comparator, iffromElementdoes not implementComparable). Implementations may, but are not required to, throw this exception iffromElementcannot be compared to elements currently in this multi-set.java.lang.NullPointerException- iffromElementisnulland this multi-set does not permitnullelements.java.lang.IllegalArgumentException- if this multi-set itself has a restricted range, andfromElementlies outside the bounds of the range.
-
subSet
SortedMultiSet<T> subSet(T fromElement, T toElement)
Returns a view of the portion of this multi-set whose elements range fromfromElementinclusively totoElementexclusively. The returned multi-set is backed by this multi-set, so changes in the returned set are reflected in this multi-set, and vice-versa. The returned multi-set supports all optional multi-set operations that this multi-set supports.The returned multi-set will throw an
IllegalArgumentExceptionon an attempt to insert an element outside its range.- Parameters:
fromElement- low endpoint (inclusive) of the returned multi-set.toElement- high endpoint (exclusive) of the returned multi-set.- Returns:
- a view of the portion of this multi-set
from
fromElementinclusively totoElementexclusively. - Throws:
java.lang.ClassCastException- **** maybe original documentation wrong. **** iffromElementandtoElementcannot be compared to one another using this set's comparator (or, if the set has no comparator, using natural ordering). or iffromElementis not compatible with this multi-set's comparator (or, if the set has no comparator, iffromElementdoes not implementComparable). Implementations may, but are not required to, throw this exception iffromElementortoElementcannot be compared to elements currently in this multi-set.java.lang.NullPointerException- iffromElementortoElementisnulland this multi-set does not permitnullelements.java.lang.IllegalArgumentException- iffromElementis greater thantoElementor if this multi-set itself has a restricted range, andfromElementortoElementlies outside the bounds of the range.
-
-