/** * Method to insert an existing node at the head of the list * * @param toInsert the existing node to insert at the head of the list. */ public void insertHead(TwoNodeCBr4 toInsert) { toInsert.setPrev(first); toInsert.setNext(first.getNext()); first.getNext().setPrev(toInsert); first.setNext(toInsert); length++; }
/** * Method to insert a node after a specified node in the list. * * @param pos Node to insert after. * @param toInsert Node to insert. */ public void insertAfter(TwoNodeCBr4 pos, TwoNodeCBr4 toInsert) { toInsert.setPrev(pos); toInsert.setNext(pos.getNext()); pos.getNext().setPrev(toInsert); pos.setNext(toInsert); length++; }
public TwoNodeCBr4 findWhereToInsert(double distance) { TwoNodeCBr4 temp = first.getNext(); while (temp != last && distance > temp.getKey()) { temp = temp.getNext(); } return temp; }
/** * Method to return the list as a comma-delimited string. * * @return the list as a string. */ public String toString() { String s = ""; TwoNodeCBr4 temp = first.getNext(); while (temp != last) { s += temp.toString(); // s += temp.getData() + " " + temp.getCount() + "\n"; temp = temp.getNext(); } return s; }
public IdealTetrahedron[] getSurroundingCBr4() { IdealTetrahedron[] surrounding = new IdealTetrahedron[length]; int index = 0; TwoNodeCBr4 temp = first.getNext(); while (temp != last) { surrounding[index] = temp.getValue(); index++; temp = temp.getNext(); } return surrounding; }
public TwoNodeCBr4 removeHead() { TwoNodeCBr4 temp = first.getNext(); temp.getNext().setPrev(first); first.setNext(temp.getNext()); temp.setNext(null); temp.setPrev(null); length--; return temp; }
public void insert(TwoNodeCBr4 cBr4) { TwoNodeCBr4 temp = findWhereToInsert(cBr4.getKey()); if (length == maxLength && temp.getNext() != last) { insertBefore(temp, cBr4); removeLast(); } if (length < maxLength) { insertBefore(temp, cBr4); } }
/** * Method to insert a new Node at the head of the list * * @param data1 first object to be contained in the node. * @param data2 second object to be contained in the node. */ public void insertHead(IdealTetrahedron value) { first.getNext().setPrev(new TwoNodeCBr4(value, 0, first, first.getNext())); first.setNext(first.getNext().getPrev()); length++; }
public boolean hasMore() { if (first.getNext() == last) { return false; } return true; }
/** * Method to remove a specified node from the list. * * @param toRemove Node to remove. * @return Node that was removed. */ public TwoNodeCBr4 remove(TwoNodeCBr4 toRemove) { toRemove.getPrev().setNext(toRemove.getNext()); toRemove.getNext().setPrev(toRemove.getPrev()); length--; return toRemove; }