|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.collection.DoublyLinkedList<E>
public class DoublyLinkedList<E>
Provides a doubly-linked list. Unlike the LinkedList class in the
JDK, DoublyLinkedList provides 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 class is not thread-safe.
DoublyLinkedList dll = new DoublyLinkedList();
dll.addLast("Abby");
dll.addLast("Bob");
dll.addLast("Chris");
ListElement<String> dan = dll.addLast("Dan");
for(DoublyLinkedList.ListElement<String> e : dll)
System.out.println(e.getKey());
dll.remove(dan);
System.out.println("");
for(DoublyLinkedList.ListElement<String> e : dll)
System.out.println(e.getKey());
Output:
Abby
Bob
Chris
Dan
Abby
Bob
Chris
| Nested Class Summary | |
|---|---|
static class |
DoublyLinkedList.ListElement<E>
Represents an immutable element of the linked list. |
| Constructor Summary | |
|---|---|
DoublyLinkedList()
Creates new empty DoublyLinkedList. |
|
| Method Summary | |
|---|---|
DoublyLinkedList.ListElement<E> |
addLast(E 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> e)
Returns true if this contains the given ListElement. |
java.util.Iterator<DoublyLinkedList.ListElement<E>> |
iterator()
|
void |
remove(DoublyLinkedList.ListElement<E> element)
Removes the specified element from the list. |
DoublyLinkedList.ListElement<E> |
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 |
|---|
public DoublyLinkedList()
| Method Detail |
|---|
public DoublyLinkedList.ListElement<E> addLast(E value)
value - the value of the new element
public DoublyLinkedList.ListElement<E> removeFirst()
public void remove(DoublyLinkedList.ListElement<E> element)
element - the element to be removed. This must be an element
of this.public void clear()
public java.util.Iterator<DoublyLinkedList.ListElement<E>> iterator()
iterator in interface java.lang.Iterable<DoublyLinkedList.ListElement<E>>public boolean contains(DoublyLinkedList.ListElement<E> e)
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||