package list.dl; import list.dl.algo.IAlgoLeft; import list.dl.algo.IAlgoRight; /** * Models a node in a doubly-linked list. Represents the state of the parent list. */ abstract class ANode { abstract Object leftFirst(DLList parent); abstract Object rightFirst(DLList parent); abstract DLList leftRest(DLList parent); abstract DLList rightRest(DLList parent); /** * Replaces the first element of the parent left list with the given data element. * @param dat the element that is to replace the first element on the left of the parent list. * @param parent the DLList that holds this ANode. */ abstract void setLeftFirst(Object dat, DLList parent); /** * Replaces the first element of the parent right list with the given data element. * @param dat the element that is to replace the first element on the left of the parent list. * @param parent the DLList that holds this ANode. */ abstract void setRightFirst(Object dat, DLList parent); /** * Replaces the left list with the given list. * @param dllist the new tail that is to replace the current one. * @param parent the DLList that holds this ANode. */ abstract void setLeftRest(DLList dllist, DLList parent); /** * Replaces the right list with the given list. * @param dllist the new tail that is to replace the current one. * @param parent the DLList that holds this ANode. */ abstract void setRightRest(DLList dllist, DLList parent); /** * Sets the left parent link. */ abstract void setLeftParent (DLList dllist); /** * Sets the right parent link. */ abstract void setRightParent (DLList dllist); /** * Inserts a data element to the left front of the parent list. * @param dat the element to be inserted to the left front of the parent. * @param parent the DLList that holds this ANode. */ abstract void insertLeftFront(Object dat, DLList parent); /** * Inserts a data element to the right front of the parent list. * @param dat the element to be inserted to the right front of the parent. * @param parent the DLList that holds this ANode. */ abstract void insertRightFront(Object dat, DLList parent); /** * Removes and returns the first element on the left of the parent DLList. * @param parent the DLList that holds this ANode. */ abstract Object remLeftFirst(DLList parent); /** * Removes and returns the first element on the right of the parent DLList. * @param parent the DLList that holds this ANode. */ abstract Object remRightFirst(DLList parent); /** * @param algo * @param input * @param parentList */ abstract Object executeLeft(IAlgoLeft algo, Object input, DLList ownerList); /** * @param algo * @param inputParam * @param parentList */ abstract Object executeRight(IAlgoRight algo, Object input, DLList parentList); }