|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectbyucc.jhdl.base.list.TreeList
This list structure is based on a modified binary tree design. Each object keeps track
of its next sibling and its first child. This is useful for objects that are guaranteed
to appear only once, on a single list. Insert, init, atEnd, next are all O(1), append and
prev are not presently supported, and elementCount is O(n).
To make a treelist of objects, the target class must implement TreeListable.
| Constructor Summary | |
TreeList()
|
|
| Method Summary | |
protected void |
append(TreeListable obj)
Append not supported at present. |
boolean |
atEnd()
Returns true when the current pointer is at the end of the list. |
boolean |
delete(TreeListable obj)
If found, deletes the child from the list of children, then reinitializes list |
int |
elementCount()
Returns the size of the list; i.e. |
java.util.Enumeration |
elements()
Returns an enumeration for safe simultaneous traversal of this list |
boolean |
empty()
Returns true if the list has no elements |
protected TreeListable |
getElt()
Returns the object pointed to by the current pointer. |
void |
init()
Initializes the list to start at the first child, for traversal. |
boolean |
inList(java.lang.Object obj)
Returns true if the object is found in the list |
boolean |
inList(TreeListable obj)
Returns true if the object is found in the list |
protected void |
insert(TreeListable obj)
Inserts a child to the list |
void |
next()
Advances the current pointer, for iterating through the list. |
void |
prev()
Prev not supported at present. |
java.lang.String |
toString()
For nice output; useful in debugging. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TreeList()
| Method Detail |
protected void insert(TreeListable obj)
obj - the child to insertpublic boolean delete(TreeListable obj)
obj - the child to delete
public final boolean empty()
public final void init()
init in interface Listpublic final boolean atEnd()
atEnd in interface Listpublic final void next()
next in interface Listpublic final void prev()
prev in interface Listprotected TreeListable getElt()
public final int elementCount()
elementCount in interface Listprotected void append(TreeListable obj)
public final boolean inList(java.lang.Object obj)
inList in interface Listpublic final boolean inList(TreeListable obj)
public java.lang.String toString()
public java.util.Enumeration elements()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||