Quadcap Embeddable Database

com.quadcap.util.DList Class Reference

List of all members.

Detailed Description

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

Definition at line 56 of file DList.java.

Public Member Functions

 DList ()
 Construct an empty DList.

void resize (int newsize)
 Make the DList a specified size, adding null entries or deleting tail entries.

int size ()
 Return the number of items in the list.

DListItem addFront (Object obj)
 Add an object to the front of the list.

void addAfter (DListItem d, Object obj)
 Add an object after an existing list item.

void addBefore (DListItem d, Object obj)
 Add an object before an existing list item.

DListItem addBack (Object obj)
 Add an object to the back of the list.

DListItem head () throws ListException
 Access the object at the front of the list.

DListItem tail () throws ListException
 Access the object at the back of the list.

DListItem popFront () throws ListException
 Remove and return the item at the front of the list.

DListItem popBack () throws ListException
 Remove and return the item at the back of the list.

String toString ()
 This method returns a string containing the display representation of this list.

void show (PrintWriter os, String delim)
 This method displays a list on the specified output stream.

void show (PrintStream os)
 This method displays a list using commas as delimiters.

void show (PrintWriter os)
 This method displays a list using commas as delimiters.

final void moveFront (DListItem d)
 Move the specified item, which is assumed to be already in the list, to the front of this list.

final void unlink (DListItem d)
Enumeration elements ()
 Return an enumeration of all of the items in this list.


Package Functions

final void addFront (DListItem d)
final void addBack (DListItem d)

Package Attributes

int size
 The number of entries in the list.

DListItem head
 The head of the list, null if the list is empty.


Constructor & Destructor Documentation

com.quadcap.util.DList.DList  ) 
 

Construct an empty DList.

Definition at line 68 of file DList.java.

References com.quadcap.util.DList.head, and com.quadcap.util.DList.size.


Member Function Documentation

void com.quadcap.util.DList.addAfter DListItem  d,
Object  obj
 

Add an object after an existing list item.

Parameters:
d the item after which the object is added
obj the object to add

Definition at line 115 of file DList.java.

References com.quadcap.util.DList.addAfter(), com.quadcap.util.DListItem.next, and com.quadcap.util.DListItem.prev.

Referenced by com.quadcap.util.DList.addAfter().

final void com.quadcap.util.DList.addBack DListItem  d  )  [package]
 

Definition at line 271 of file DList.java.

References com.quadcap.util.DListItem.next, and com.quadcap.util.DListItem.prev.

DListItem com.quadcap.util.DList.addBack Object  obj  ) 
 

Add an object to the back of the list.

Parameters:
obj the object to add

Definition at line 141 of file DList.java.

References com.quadcap.util.DList.addBack().

Referenced by com.quadcap.util.DList.addBack(), and com.quadcap.util.DList.resize().

void com.quadcap.util.DList.addBefore DListItem  d,
Object  obj
 

Add an object before an existing list item.

Parameters:
d the item before which the object is added
obj the object to add

Definition at line 129 of file DList.java.

References com.quadcap.util.DList.addBefore(), com.quadcap.util.DListItem.next, and com.quadcap.util.DListItem.prev.

Referenced by com.quadcap.util.DList.addBefore().

final void com.quadcap.util.DList.addFront DListItem  d  )  [package]
 

Definition at line 265 of file DList.java.

DListItem com.quadcap.util.DList.addFront Object  obj  ) 
 

Add an object to the front of the list.

Parameters:
obj the object to add

Definition at line 103 of file DList.java.

References com.quadcap.util.DList.addFront().

Referenced by com.quadcap.util.DList.addFront().

Enumeration com.quadcap.util.DList.elements  ) 
 

Return an enumeration of all of the items in this list.

Definition at line 297 of file DList.java.

References com.quadcap.util.DList.head, com.quadcap.util.DListItem.next, and com.quadcap.util.DListItem.obj.

DListItem com.quadcap.util.DList.head  )  throws ListException
 

Access the object at the front of the list.

Throw an exception if the list is empty.

Returns:
the item at the head of the list

Definition at line 153 of file DList.java.

final void com.quadcap.util.DList.moveFront DListItem  d  ) 
 

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.

Definition at line 252 of file DList.java.

References com.quadcap.util.DList.moveFront(), com.quadcap.util.DListItem.next, and com.quadcap.util.DListItem.prev.

Referenced by com.quadcap.util.DList.moveFront().

DListItem com.quadcap.util.DList.popBack  )  throws ListException
 

Remove and return the item at the back of the list.

Returns:
the item at the tail of the list

Definition at line 188 of file DList.java.

References com.quadcap.util.DListItem.next, com.quadcap.util.DListItem.prev, and com.quadcap.util.DList.unlink().

Referenced by com.quadcap.util.DList.resize().

DListItem com.quadcap.util.DList.popFront  )  throws ListException
 

Remove and return the item at the front of the list.

Returns:
the item at the head of the list

Definition at line 174 of file DList.java.

References com.quadcap.util.DListItem.next, and com.quadcap.util.DList.unlink().

void com.quadcap.util.DList.resize int  newsize  ) 
 

Make the DList a specified size, adding null entries or deleting tail entries.

Parameters:
newsize the new size of the list

Definition at line 79 of file DList.java.

References com.quadcap.util.DList.addBack(), com.quadcap.util.DList.popBack(), com.quadcap.util.DList.resize(), and com.quadcap.util.DList.size.

Referenced by com.quadcap.util.DList.resize().

void com.quadcap.util.DList.show PrintWriter  os  ) 
 

This method displays a list using commas as delimiters.

Parameters:
os the PrintWriter on which to display this list.

Definition at line 238 of file DList.java.

void com.quadcap.util.DList.show PrintStream  os  ) 
 

This method displays a list using commas as delimiters.

Parameters:
os the PrintStream on which to display this list.

Definition at line 229 of file DList.java.

void com.quadcap.util.DList.show PrintWriter  os,
String  delim
 

This method displays a list on the specified output stream.

Definition at line 209 of file DList.java.

References com.quadcap.util.DListItem.next, com.quadcap.util.DListItem.obj, and com.quadcap.util.DList.show().

Referenced by com.quadcap.util.DList.show(), and com.quadcap.util.DList.toString().

int com.quadcap.util.DList.size  ) 
 

Return the number of items in the list.

Returns:
the list's size

Definition at line 94 of file DList.java.

DListItem com.quadcap.util.DList.tail  )  throws ListException
 

Access the object at the back of the list.

Throw an exception if the list is empty.

Returns:
the item at the tail of the list

Definition at line 164 of file DList.java.

References com.quadcap.util.DListItem.prev.

String com.quadcap.util.DList.toString  ) 
 

This method returns a string containing the display representation of this list.

Definition at line 200 of file DList.java.

References com.quadcap.util.DList.show().

final void com.quadcap.util.DList.unlink DListItem  d  ) 
 

Definition at line 281 of file DList.java.

References com.quadcap.util.DListItem.next, com.quadcap.util.DListItem.prev, and com.quadcap.util.DList.unlink().

Referenced by com.quadcap.util.DList.popBack(), com.quadcap.util.DList.popFront(), and com.quadcap.util.DList.unlink().


Member Data Documentation

DListItem com.quadcap.util.DList.head [package]
 

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.

Definition at line 63 of file DList.java.

Referenced by com.quadcap.util.DList.DList(), and com.quadcap.util.DList.elements().

int com.quadcap.util.DList.size [package]
 

The number of entries in the list.

We are careful to track the size accurately.

Definition at line 59 of file DList.java.

Referenced by com.quadcap.util.DList.DList(), and com.quadcap.util.DList.resize().