| java.lang.Object com.quadcap.util.DList
DList | public class DList (Code) | | This class manages a doubly linked list, with head and tail. It's
actually implemented as a circular list, with a single head pointer,
and the tail is head.prev .
It would be good to have list primitives that worked well moving items
from one list to another. moveFront(), in particular, should be able
to splice an object out of one list and put it at the front of a
different list.
author: Stan Bailes |
Field Summary | |
DListItem | head The head of the list, null if the list is empty. | int | size The number of entries in the list. |
Constructor Summary | |
public | DList() Construct an empty DList. |
head | DListItem head(Code) | | The head of the list, null if the list is empty. Also, an indirect
pointer to the tail of the list, since the list is linked circularly.
|
size | int size(Code) | | The number of entries in the list. We are careful to track the
size accurately.
|
DList | public DList()(Code) | | Construct an empty DList.
|
addAfter | public void addAfter(DListItem d, Object obj)(Code) | | Add an object after an existing list item.
Parameters: d - the item after which the object is added Parameters: obj - the object to add |
addBack | public DListItem addBack(Object obj)(Code) | | Add an object to the back of the list.
Parameters: obj - the object to add |
addBefore | public void addBefore(DListItem d, Object obj)(Code) | | Add an object before an existing list item.
Parameters: d - the item before which the object is added Parameters: obj - the object to add |
addFront | public DListItem addFront(Object obj)(Code) | | Add an object to the front of the list.
Parameters: obj - the object to add |
elements | public Enumeration elements()(Code) | | Return an enumeration of all of the items in this list.
|
head | public DListItem head() throws ListException(Code) | | Access the object at the front of the list. Throw an exception
if the list is empty.
the item at the head of the list |
moveFront | final public void moveFront(DListItem d)(Code) | | Move the specified item, which is assumed to be already in the
list, to the front of this list.
Parameters: d - the item to be placed at the front of this list. |
popBack | public DListItem popBack() throws ListException(Code) | | Remove and return the item at the back of the list.
the item at the tail of the list |
popFront | public DListItem popFront() throws ListException(Code) | | Remove and return the item at the front of the list.
the item at the head of the list |
resize | public void resize(int newsize)(Code) | | Make the DList a specified size, adding null entries or deleting
tail entries.
Parameters: newsize - the new size of the list |
show | public void show(PrintWriter os, String delim)(Code) | | This method displays a list on the specified output stream.
|
show | public void show(PrintStream os)(Code) | | This method displays a list using commas as delimiters.
Parameters: os - the PrintStream on which to display this list. |
show | public void show(PrintWriter os)(Code) | | This method displays a list using commas as delimiters.
Parameters: os - the PrintWriter on which to display this list. |
size | public int size()(Code) | | Return the number of items in the list.
the list's size |
tail | public DListItem tail() throws ListException(Code) | | Access the object at the back of the list. Throw an exception
if the list is empty.
the item at the tail of the list |
toString | public String toString()(Code) | | This method returns a string containing the display representation
of this list.
|
|
|