| java.lang.Object com.sun.perseus.util.DoublyLinkedList
DoublyLinkedList | public class DoublyLinkedList (Code) | | A simple Doubly Linked list class, designed to avoid
O(n) behaviour on insert and delete.
author: Thomas DeWeese version: $Id: DoublyLinkedList.java,v 1.2 2006/04/21 06:35:47 st125089 Exp $ |
Inner Class :public static class Node | |
Method Summary | |
public void | add(Node nde) Adds nde to the head of the list.
In perl this is called an 'unpop'. | public void | empty() Removes all elements from the list. | public Node | getHead() | public int | getSize() | public Node | getTail() | public Node | pop() Removes 'head' from list and returns it. | public void | push(Node nde) | public void | remove(Node nde) Removes nde from the list it is part of (should be this
one, otherwise results are undefined). | public void | unpop(Node nde) | public Node | unpush() Removes 'tail' from list and returns it. |
DoublyLinkedList | public DoublyLinkedList()(Code) | | Default constructor
|
add | public void add(Node nde)(Code) | | Adds nde to the head of the list.
In perl this is called an 'unpop'. nde should
not currently be part of any list.
Parameters: nde - the node to add to the list. |
empty | public void empty()(Code) | | Removes all elements from the list.
|
getHead | public Node getHead()(Code) | | Get the current head element
The current 'first' element in list. |
getSize | public int getSize()(Code) | | the number of elements currently in the list. |
getTail | public Node getTail()(Code) | | Get the current tail element
The current 'last' element in list. |
pop | public Node pop()(Code) | | Removes 'head' from list and returns it. Returns null if list is empty.
current head element, next element becomes head. |
push | public void push(Node nde)(Code) | | Parameters: nde - the Node to add to tail of list |
remove | public void remove(Node nde)(Code) | | Removes nde from the list it is part of (should be this
one, otherwise results are undefined). If nde is the
current head element, then the next element becomes head,
if there are no more elements the list becomes empty.
Parameters: nde - Node to remove. |
unpop | public void unpop(Node nde)(Code) | | Parameters: nde - the Node to put to the head of list |
unpush | public Node unpush()(Code) | | Removes 'tail' from list and returns it. Returns null if list is empty.
current tail element. |
|
|