예제 #1
0
 /**
  * Adds a node to the beginning of the list.
  *
  * @param node the node to add to the beginning of the list.
  */
 public LinkedListNode addFirst(LinkedListNode node) {
   node.next = head.next;
   node.previous = head;
   node.previous.next = node;
   node.next.previous = node;
   return node;
 }
예제 #2
0
  /** Erases all elements in the list and re-initializes it. */
  public void clear() {
    // Remove all references in the list.
    LinkedListNode node = getLast();
    while (node != null) {
      node.remove();
      node = getLast();
    }

    // Re-initialize.
    head.next = head.previous = head;
  }
예제 #3
0
 /** Creates a new linked list. */
 public LinkedList() {
   head.next = head.previous = head;
 }
예제 #4
0
파일: Cache.java 프로젝트: noschinl/Smack
 /** Removes this node from the linked list that it is a part of. */
 public void remove() {
   previous.next = next;
   next.previous = previous;
 }