public DoubleLinkedList() { head = new LinkedHead(this); tail = new LinkedTail(this); currentItteration = tail; this.listSize = 0; }
public void getRemove() { LinkedNodeElement currentNode = this.currentItteration; this.currentItteration = this.currentItteration.getNextNode(); currentNode.removeSelf(); }
public T get() { LinkedNodeElement currentNode = this.currentItteration; this.currentItteration = this.currentItteration.getNextNode(); return(currentNode.getElement()); }
public LinkedNodeElement addElement(T element, DoubleLinkedList <T> list) { LinkedNodeElement newNode = new LinkedNodeElement(element, list); newNode.setNextNode(this.nextNode); // Head Add --> Tail^ order of these is important newNode.setPreviousNode(this); // Head <-- Add Tail this.nextNode.setPreviousNode(newNode); // Head Add <-- Tail^ this.nextNode = newNode; // Head --> Add Tail** change this.nextNode from tail to add LAST return(newNode); }
public ListNodeTicket <T> add(T element) { try { LinkedNodeElement newElement = this.head.addElement(element, this); currentItteration = newElement; listSize++; return(new ListNodeTicket <T>(newElement)); } catch (InvalidCastException e) { //System.err.println("Attempted to add entity without Composite DoubleLinkedList."); return(null); } }
public void setNextNode(LinkedNodeElement nextNode) { this.nextNode = nextNode; }