package rac; /** * The abstract node of a doubly-linked Lisp-like circular list. * @author S. Wong */ public abstract class ARACNode{ protected ARACNode next; protected ARACNode previous; /** * Accessor method to get the next node in the doubly linked circular list. * @return An abstract node */ public ARACNode getNext() { return next; } /** * Accessor method to get the previous node in the doubly-linked circular list. * @return An abstract node */ public ARACNode getPrevious() { return previous; } /** * Accessor method to set the next node of the doubly linked circular list. * The remaining links to the node are NOT established. * @param next The new next node. */ protected void setNext(ARACNode next) { this.next = next; } /** * Accessor method to set the previous node of the doubly linked circular list. * The remaining links to the node are NOT established. * @param previous The new previous node. */ protected void setPrevious(ARACNode previous) { this.previous = previous; } /** * Inserts the supplied data into a new previous node of the current node. * The links to the new node are automatically established. * @param data The data to inserts */ public void insertPrevious(Object data) { previous.insertNext(data); } /** * Inserts the supplied data as a new next node of the current node. * The links to the new node are automatically established. * @param data The data to store. */ public void insertNext(Object data) { ARACNode tmpNext = next; next = new RACDataNode(data, tmpNext, this); tmpNext.setPrevious(next); } /** * Abstract method that removes the current node, returning its data. * The links to/from this node are automatically connected. * @return The data stored in the current node. */ public abstract Object removeNode(); /** * Generalized abstract method to execute a visitor design pattern IRACVisitor algorithm on the doubly linked circular list. * @param param An generalized parameter for use by the visiting algorithm. * @param visitor An IRACVisitor algorithm to be executed on the list. * @return A genrealized output from the algorithm. */ public abstract Object execute(IRACVisitor visitor, Object param); }