Package craterdog.core
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>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidinsertElement(E element) This method inserts a new element in the slot currently pointed at by the manipulator.abstract EThis method removes the element after the slot where the manipulator is currently pointing.abstract EThis method removes the element before the slot where the manipulator is currently pointing.Methods inherited from class craterdog.core.Iterator
getNext, getPrevious, hasNext, hasPrevious, next, remove, toEnd, toIndex, toStartMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
Manipulator
public Manipulator()
-
-
Method Details
-
insertElement
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
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
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.
-