/**
  * 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++;
 }
 /**
  * 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++;
 }
  public TwoNodeCBr4 removeHead() {
    TwoNodeCBr4 temp = first.getNext();

    temp.getNext().setPrev(first);

    first.setNext(temp.getNext());

    temp.setNext(null);
    temp.setPrev(null);

    length--;

    return temp;
  }
 /**
  * Constructor to initialize the head and tail of the list to each other with null data in each.
  */
 public DoubleLinkedListCBr4(int maxLength) {
   first = new TwoNodeCBr4(null, 0, null, null);
   last = new TwoNodeCBr4(null, 0, null, null);
   first.setNext(last);
   last.setPrev(first);
   length = 0;
   this.maxLength = maxLength;
 }
  public TwoNodeCBr4 removeLast() {
    TwoNodeCBr4 temp = last.getPrev();
    last.setPrev(last.getPrev().getPrev());
    last.getPrev().setNext(last);

    temp.setNext(null);
    temp.setPrev(null);

    length--;

    return temp;
  }
 /**
  * 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 void clear() {
   first.setNext(last);
   last.setPrev(first);
   length = 0;
 }