com.limegroup.gnutella.util
Class DoublyLinkedList

java.lang.Object
  extended bycom.limegroup.gnutella.util.DoublyLinkedList

public class DoublyLinkedList
extends java.lang.Object

A classic doubly-linked list. Unlike the LinkedList class in the JDK, this provides way a way to refer to elements of the list (each of type ListElement) directly, avoiding linear-time searches when you wish to remove an element. This currently only has a minimal set of operations.

This class is not thread-safe. All the access to the list should be synchronized externally if required.


Nested Class Summary
static class DoublyLinkedList.ListElement
          An element of the linked list.
 
Constructor Summary
DoublyLinkedList()
          Creates new empty DoublyLinkedList
 
Method Summary
 DoublyLinkedList.ListElement addLast(java.lang.Object value)
          Inserts an object at the end of the list, returning its corresponding element.
 void clear()
          Removes all entries from this list
 boolean contains(DoublyLinkedList.ListElement e)
          Returns true if this contains the given ListElement.
 java.util.Iterator iterator()
           
 void remove(DoublyLinkedList.ListElement element)
          Removes the specified element from the list
 DoublyLinkedList.ListElement removeFirst()
          Removes and returns the first element from the list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoublyLinkedList

public DoublyLinkedList()
Creates new empty DoublyLinkedList

Method Detail

addLast

public DoublyLinkedList.ListElement addLast(java.lang.Object value)
Inserts an object at the end of the list, returning its corresponding element.

Parameters:
value - the value of the new element.
Returns:
the element holding value.

removeFirst

public DoublyLinkedList.ListElement removeFirst()
Removes and returns the first element from the list

Returns:
The element removed, or null if none present

remove

public void remove(DoublyLinkedList.ListElement element)
Removes the specified element from the list

Parameters:
element - The element to be removed. This must be an element of this.

clear

public void clear()
Removes all entries from this list


iterator

public java.util.Iterator iterator()

contains

public boolean contains(DoublyLinkedList.ListElement e)
Returns true if this contains the given ListElement.