Package eu.simuline.util
Class CollectionsExt.ImmutableSortedMultiSet<E>
- java.lang.Object
-
- eu.simuline.util.CollectionsExt.AbstractImmutableMultiSet<SortedMultiSet<E>,E>
-
- eu.simuline.util.CollectionsExt.ImmutableSortedMultiSet<E>
-
- Type Parameters:
E- the class of the elements of this list.
- All Implemented Interfaces:
MultiSet<E>,SortedMultiSet<E>,java.lang.Iterable<E>
- Enclosing class:
- CollectionsExt<E>
static class CollectionsExt.ImmutableSortedMultiSet<E> extends CollectionsExt.AbstractImmutableMultiSet<SortedMultiSet<E>,E> implements SortedMultiSet<E>
A sorted multi-set which prevents being modified by throwing an exception for the modifying methods.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface eu.simuline.util.MultiSet
MultiSet.Multiplicity
-
-
Field Summary
Fields Modifier and Type Field Description private SortedMultiSet<E>mSet
-
Constructor Summary
Constructors Constructor Description ImmutableSortedMultiSet(SortedMultiSet<E> mSet)Creates a new emptyImmutableSortedMultiSetwhich equalsmSetbut cannot be modified neither directly nor via its iterator.ImmutableSortedMultiSet(java.util.Set<CollectionsExt.Modification> mods, SortedMultiSet<E> mSet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Comparator<? super E>comparator()Returns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.Efirst()Returns the first (lowest) element currently in this set.java.util.NavigableMap<E,MultiSet.Multiplicity>getMap()Returns a view of the underlying map of thisMultiSetas a map mapping each entry to its multiplicity.java.util.SortedSet<E>getSet()Returns a view of the underlying set of thisMultiSet.SortedMultiSet<E>headSet(E toElement)Returns a view of the portion of this multi-set whose elements are strictly less thantoElement.Elast()Returns the last (highest) element currently in this set.SortedMultiSet<E>subSet(E fromElement, E toElement)Returns a view of the portion of this multi-set whose elements range fromfromElementinclusively totoElementexclusively.SortedMultiSet<E>tailSet(E fromElement)Returns a view of the portion of this multi-set whose elements are greater than or equal tofromElement.SortedMultiSet<E>unrestricted()Returns the underlying multiset without the restrictions imposed by thisCollectionsExt.ImmutableCollection.-
Methods inherited from class eu.simuline.util.CollectionsExt.AbstractImmutableMultiSet
add, addAll, addAll, addWithMult, addWithMult, allowedModifications, clear, contains, containsAll, equals, getMaxMult, getMultiplicity, getMultiplicityObj, getObjWithMaxMult, getSetWithMults, hashCode, isEmpty, iterator, remove, removeAll, removeWithMult, removeWithMult, retainAll, setMultiplicity, size, sizeWithMult, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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
-
-
-
-
Field Detail
-
mSet
private final SortedMultiSet<E> mSet
-
-
Constructor Detail
-
ImmutableSortedMultiSet
ImmutableSortedMultiSet(SortedMultiSet<E> mSet)
Creates a new emptyImmutableSortedMultiSetwhich equalsmSetbut cannot be modified neither directly nor via its iterator. y- Throws:
java.lang.NullPointerException- ifcoll==null.
-
ImmutableSortedMultiSet
ImmutableSortedMultiSet(java.util.Set<CollectionsExt.Modification> mods, SortedMultiSet<E> mSet)
-
-
Method Detail
-
unrestricted
public SortedMultiSet<E> unrestricted()
Description copied from class:CollectionsExt.AbstractImmutableMultiSetReturns the underlying multiset without the restrictions imposed by thisCollectionsExt.ImmutableCollection. Note that the result may still throwUnsupportedOperationExceptions depending on the implementation.- Specified by:
unrestrictedin classCollectionsExt.AbstractImmutableMultiSet<SortedMultiSet<E>,E>
-
getSet
public java.util.SortedSet<E> getSet()
Description copied from interface:MultiSetReturns a view of the underlying set of thisMultiSet. For certain implementations, this set is immutable to prevent implicit modification of thisMultiSet.- Specified by:
getSetin interfaceMultiSet<E>- Specified by:
getSetin interfaceSortedMultiSet<E>- Overrides:
getSetin classCollectionsExt.AbstractImmutableMultiSet<SortedMultiSet<E>,E>- Returns:
- the
Setcontaining exactly the objects with strictly positive multiplicity in thisMultiSet.
-
getMap
public java.util.NavigableMap<E,MultiSet.Multiplicity> getMap()
Description copied from interface:MultiSetReturns a view of the underlying map of thisMultiSetas a map mapping each entry to its multiplicity.- Specified by:
getMapin interfaceMultiSet<E>- Specified by:
getMapin interfaceSortedMultiSet<E>- Overrides:
getMapin classCollectionsExt.AbstractImmutableMultiSet<SortedMultiSet<E>,E>
-
comparator
public java.util.Comparator<? super E> comparator()
Description copied from interface:SortedMultiSetReturns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.- Specified by:
comparatorin interfaceSortedMultiSet<E>- Returns:
- the comparator used to order the elements in this set,
or
nullif this set uses the natural ordering of its elements.
-
first
public E first()
Description copied from interface:SortedMultiSetReturns the first (lowest) element currently in this set.- Specified by:
firstin interfaceSortedMultiSet<E>- Returns:
- the first (lowest) element currently in this set
-
last
public E last()
Description copied from interface:SortedMultiSetReturns the last (highest) element currently in this set.- Specified by:
lastin interfaceSortedMultiSet<E>- Returns:
- the last (highest) element currently in this set.
-
headSet
public SortedMultiSet<E> headSet(E toElement)
Description copied from interface:SortedMultiSetReturns 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.- Specified by:
headSetin interfaceSortedMultiSet<E>- 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.
-
tailSet
public SortedMultiSet<E> tailSet(E fromElement)
Description copied from interface:SortedMultiSetReturns 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.- Specified by:
tailSetin interfaceSortedMultiSet<E>- 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.
-
subSet
public SortedMultiSet<E> subSet(E fromElement, E toElement)
Description copied from interface:SortedMultiSetReturns 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.- Specified by:
subSetin interfaceSortedMultiSet<E>- 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.
-
-