public class DoublyLinkedList
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DoublyLinkedList.Node
Basic doubly linked list node interface.
|
Constructor and Description |
---|
DoublyLinkedList() |
Modifier and Type | Method and Description |
---|---|
void |
add(DoublyLinkedList.Node nde)
Adds
nde to the head of the list. |
void |
add(int index,
DoublyLinkedList.Node nde) |
void |
empty()
Removes all elements from the list.
|
DoublyLinkedList.Node |
getHead()
Get the current head element
|
int |
getSize()
Returns the number of elements currently in the list.
|
DoublyLinkedList.Node |
getTail()
Get the current tail element
|
DoublyLinkedList.Node |
pop()
Removes 'head' from list and returns it.
|
void |
push(DoublyLinkedList.Node nde)
Adds
nde to tail of list |
void |
remove(DoublyLinkedList.Node nde)
Removes nde from the list it is part of (should be this
one, otherwise results are undefined).
|
void |
touch(DoublyLinkedList.Node nde)
Moves
nde to the head of the list (equivilent to
remove(nde); add(nde); but faster. |
void |
unpop(DoublyLinkedList.Node nde)
Adds
nde to head of list |
DoublyLinkedList.Node |
unpush()
Removes 'tail' from list and returns it.
|
public int getSize()
public void empty()
public DoublyLinkedList.Node getHead()
public DoublyLinkedList.Node getTail()
public void touch(DoublyLinkedList.Node nde)
nde
to the head of the list (equivilent to
remove(nde); add(nde); but faster.public void add(int index, DoublyLinkedList.Node nde)
public void add(DoublyLinkedList.Node nde)
nde
to the head of the list.
In perl this is called an 'unpop'. nde
should
not currently be part of any list.nde
- the node to add to the list.public void remove(DoublyLinkedList.Node nde)
nde
- node to remove.public DoublyLinkedList.Node pop()
public DoublyLinkedList.Node unpush()
public void push(DoublyLinkedList.Node nde)
nde
to tail of listpublic void unpop(DoublyLinkedList.Node nde)
nde
to head of listCopyright © 2022 Apache Software Foundation. All Rights Reserved.