Package com.swiftmq.tools.collection
Class SortedDupsCollection
java.lang.Object
java.util.AbstractCollection
com.swiftmq.tools.collection.SortedDupsCollection
- All Implemented Interfaces:
Iterable
,Collection
,Iterator
A sorted collection that allowes duplicate entries.
- Version:
- 1.0
- Author:
- Andreas Mueller, IIT GmbH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Ensures that this collection contains the specified element (optional operation).first()
boolean
hasNext()
Returns true if the iteration has more elements.iterator()
Returns an iterator over the elements contained in this collection.next()
Returns the next element in the interation.void
remove()
* Removes from the underlying collection the last element returned by the iterator (optional operation).int
size()
Returns the number of elements in this collection.Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
SortedDupsCollection
- Parameters:
baseSet
-
-
-
Method Details
-
add
Ensures that this collection contains the specified element (optional operation). Returns true if the collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.) Collections that support this operation may place limitations on what elements may be added to the collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.This implementation always throws an UnsupportedOperationException.
- Specified by:
add
in interfaceCollection
- Overrides:
add
in classAbstractCollection
- Parameters:
o
- element whose presence in this collection is to be ensured.- Returns:
- true if the collection changed as a result of the call.
- Throws:
UnsupportedOperationException
- if the add method is not supported by this collection.NullPointerException
- if this collection does not permit null elements, and the specified element is null.ClassCastException
- if the class of the specified element prevents it from being added to this collection.IllegalArgumentException
- if some aspect of this element prevents it from being added to this collection.
-
first
-
iterator
Returns an iterator over the elements contained in this collection. *- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
- Specified by:
iterator
in classAbstractCollection
- Returns:
- an iterator over the elements contained in this collection.
-
size
public int size()Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE. *- Specified by:
size
in interfaceCollection
- Specified by:
size
in classAbstractCollection
- Returns:
- the number of elements in this collection.
-
hasNext
public boolean hasNext()Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.) * -
next
Returns the next element in the interation. * -
remove
public void remove()* Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method. *
-