Class Manipulator<E>

java.lang.Object
craterdog.core.Iterator<E>
craterdog.core.Manipulator<E>
Type Parameters:
E - The type of the element being manipulated.
All Implemented Interfaces:
Iterator<E>

public abstract class Manipulator<E> extends Iterator<E>
This abstract class extends the Iterator class by allowing the manipulation of the sequence's elements. Just like an iterator, a manipulator points at the slots on either side of the elements in a sequence.
            [element 1]   [element 2]   [element 3]  ...  [element N]
          ^             ^             ^             ^   ^             ^
       at start                                                    at end
 
Author:
Derk Norton
  • Constructor Details

    • Manipulator

      public Manipulator()
  • Method Details

    • insertElement

      public abstract void insertElement(E element)
      This method inserts a new element in the slot currently pointed at by the manipulator. If this sequence is empty then the new element becomes the first element in the sequence.
      Parameters:
      element - The new element to be inserted.
    • removeNext

      public abstract E removeNext()
      This method removes the element after the slot where the manipulator is currently pointing. If the manipulator is at the end of this sequence an exception is thrown.
      Returns:
      The removed next element.
    • removePrevious

      public abstract E removePrevious()
      This method removes the element before the slot where the manipulator is currently pointing. If the manipulator is at the start of this sequence an exception is thrown.
      Returns:
      The removed previous element.