Class SortedDupsCollection

java.lang.Object
java.util.AbstractCollection
com.swiftmq.tools.collection.SortedDupsCollection
All Implemented Interfaces:
Iterable, Collection, Iterator

public class SortedDupsCollection extends AbstractCollection implements Iterator
A sorted collection that allowes duplicate entries.
Version:
1.0
Author:
Andreas Mueller, IIT GmbH
  • Constructor Details

    • SortedDupsCollection

      public SortedDupsCollection(SortedSet baseSet)
      Parameters:
      baseSet -
  • Method Details

    • add

      public boolean add(Object o)
      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 interface Collection
      Overrides:
      add in class AbstractCollection
      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

      public Object first()
    • iterator

      public Iterator iterator()
      Returns an iterator over the elements contained in this collection. *
      Specified by:
      iterator in interface Collection
      Specified by:
      iterator in interface Iterable
      Specified by:
      iterator in class AbstractCollection
      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 interface Collection
      Specified by:
      size in class AbstractCollection
      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.) *
      Specified by:
      hasNext in interface Iterator
      Returns:
      true if the iterator has more elements.
    • next

      public Object next()
      Returns the next element in the interation. *
      Specified by:
      next in interface Iterator
      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. *
      Specified by:
      remove in interface Iterator