Class SortedDupsCollection

  • All Implemented Interfaces:
    java.lang.Iterable, java.util.Collection, java.util.Iterator

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

      Constructors 
      Constructor Description
      SortedDupsCollection​(java.util.SortedSet baseSet)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.Object o)
      Ensures that this collection contains the specified element (optional operation).
      java.lang.Object first()  
      boolean hasNext()
      Returns true if the iteration has more elements.
      java.util.Iterator iterator()
      Returns an iterator over the elements contained in this collection.
      java.lang.Object 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.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • SortedDupsCollection

        public SortedDupsCollection​(java.util.SortedSet baseSet)
        Parameters:
        baseSet -
    • Method Detail

      • add

        public boolean add​(java.lang.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 java.util.Collection
        Overrides:
        add in class java.util.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:
        java.lang.UnsupportedOperationException - if the add method is not supported by this collection.
        java.lang.NullPointerException - if this collection does not permit null elements, and the specified element is null.
        java.lang.ClassCastException - if the class of the specified element prevents it from being added to this collection.
        java.lang.IllegalArgumentException - if some aspect of this element prevents it from being added to this collection.
      • first

        public java.lang.Object first()
      • iterator

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

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