示例#1
0
  /**
   * Insert a node at the end of the list containing the specified data Increment the size of the
   * list each time
   *
   * @param data The data value of the new node
   */
  public void InsertNode(int data) {

    ListNode node = new LinkedList.ListNode(data);

    if (first == null) {
      first = node;
      first.next = last;
      first.previous = header;
    } else if (last == null) {
      last = node;
      last.previous = first;
      first.next = last;
    } else last.next = node;
    node.previous = last;
    last = node;

    matrixSize = matrixSize + 1;
  }
示例#2
0
  /** Sets all of the values of the list to null -- clearing the list */
  public void clearList() {

    ListNode currentNode = first;
    ListNode nextNode = null;

    first = null;
    header = null;

    while (currentNode != null) {
      nextNode = currentNode.next;
      currentNode.next = currentNode.previous = null;
      currentNode = nextNode;
    }
  }