Package qilin.util

Interface Chain<E>

Type Parameters:
E - element type
All Superinterfaces:
Collection<E>, Iterable<E>, Serializable

public interface Chain<E> extends Collection<E>, Serializable
Augmented data type guaranteeing O(1) insertion and removal from a set of ordered, unique elements.
  • Method Details

    • insertBefore

      void insertBefore(E toInsert, E point)
      Inserts toInsert in the Chain before point.
    • insertAfter

      void insertAfter(E toInsert, E point)
      Inserts toInsert in the Chain after point.
    • insertBefore

      void insertBefore(Chain<E> toInsert, E point)
      Inserts toInsert in the Chain before point.
    • insertAfter

      void insertAfter(Chain<E> toInsert, E point)
      Inserts toInsert in the Chain after point.
    • insertBefore

      void insertBefore(List<E> toInsert, E point)
      Inserts toInsert in the Chain before point.
    • insertAfter

      void insertAfter(List<E> toInsert, E point)
      Inserts toInsert in the Chain after point.
    • insertBefore

      void insertBefore(Collection<? extends E> toInsert, E point)
      Inserts toInsert in the Chain before point.
    • insertAfter

      void insertAfter(Collection<? extends E> toInsert, E point)
      Inserts toInsert in the Chain after point.
    • swapWith

      void swapWith(E out, E in)
      Replaces out in the Chain by in.
    • remove

      boolean remove(Object u)
      Removes the given object from this Chain. Parameter has to be of type Object to be compatible with the Collection interface.
      Specified by:
      remove in interface Collection<E>
    • addFirst

      void addFirst(E u)
      Adds the given object at the beginning of the Chain.
    • addLast

      void addLast(E u)
      Adds the given object at the end of the Chain.
    • removeFirst

      void removeFirst()
      Removes the first object contained in this Chain.
    • removeLast

      void removeLast()
      Removes the last object contained in this Chain.
    • follows

      boolean follows(E someObject, E someReferenceObject)
      Returns true if object someObject follows object someReferenceObject in the Chain, i.e. someReferenceObject comes first and then someObject.
    • getFirst

      E getFirst()
      Returns the first object in this Chain.
    • getLast

      E getLast()
      Returns the last object in this Chain.
    • getSuccOf

      E getSuccOf(E point)
      Returns the object immediately following point.
    • getPredOf

      E getPredOf(E point)
      Returns the object immediately preceding point.
    • snapshotIterator

      Iterator<E> snapshotIterator()
      Returns an iterator over a copy of this chain. This avoids ConcurrentModificationExceptions from being thrown if the underlying Chain is modified during iteration. Do not use this to remove elements which have not yet been iterated over!
    • iterator

      Iterator<E> iterator()
      Returns an iterator over this Chain.
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
    • iterator

      Iterator<E> iterator(E u)
      Returns an iterator over this Chain, starting at the given object.
    • iterator

      Iterator<E> iterator(E head, E tail)
      Returns an iterator over this Chain, starting at head and reaching tail (inclusive).
    • size

      int size()
      Returns the size of this Chain.
      Specified by:
      size in interface Collection<E>
    • getModificationCount

      long getModificationCount()
      Returns the number of times this chain has been modified.
    • getElementsUnsorted

      Collection<E> getElementsUnsorted()
      Gets all elements in the chain. There is no guarantee on sorting. On the other hand, the collection returned by this method is thread-safe. You can iterate over it even in the case of concurrent modifications to the underlying chain.
      Returns:
      All elements in the chain in an unsorted collection