|
|
Tree Interface
|
| boolean
|
addFirstChild (int index[], Object item)
Adds the item to this tree as the first
child of the node at the specified index. If
the index is invalid, returns false, else returns true.
Throws an exception if the item is null. Some
implementations might choose not to allow duplicates.
|
| boolean
|
addRoot (Object item)
Adds the item as the root of this tree. Throws an exception if the item is null or the
tree is nonempty, else returns true.
|
| boolean
|
addRightSibling (int index[], Object item)
Adds the item to this tree as the right
sibling of the node at the specified index. If
the index is invalid, returns false, else returns true.
Throws an exception if the item is null. Some
implementations might choose not to allow duplicates.
|
| void
|
clear ()
Removes all items from this tree.
|
| Object
|
clone ()
Returns a shallow copy of this tree.
|
| Collection
|
collectionView ()
Returns a collection view of the items
contained in this tree.
|
| boolean
|
contains (Object item)
Returns true if the specified item is in
this tree. Throws an exception if the item is
null.
|
| boolean
|
equals (Object other)
Returns true if the specified item is a
tree that equals this tree. Two tree are
considered equal if they have the same structure and equal items at each position within
this structure..
|
| Object
|
get (Object item)
Returns the first item encountered during
a preorder traversal that is equal to the specified item or null if there is none. Throws an exception if the specified item is null.
|
| Object
|
get (int index[])
Returns the item at the specified index
or null if the index is invalid.
|
| int
|
hashCode ()
Returns the hash code value for this
sorted collection.
|
| String
|
hierarchicalList ()
Returns a multi-line string that lists
the items in this tree in preorder with one node per line and with children indented more
than their parent. The result looks similar
to a book's table of contents.
|
| int[ ]
|
indexOf (Object item)
Returns the index of the first item
encountered during a preorder traversal that is equal to the specified item or {-1} if
there is none. Throws an exception if the
specified item is null.
|
| boolean
|
isEmpty ()
Returns true
if this tree contains no elements.
|
| Iterator
|
iterator ()
Returns an iterator over the items
contained in this tree. The iterator provides
the items in preorder. The iterator could
support removal, depending on the implementation.
|
| Object
|
remove (int index[])
Removes and returns the item at the
specified index position. Returns null if the
index is invalid. All the item's children are
removed also.
|
| boolean
|
remove (Object item)
Removes the first item encountered during
a preorder traversal that is equal to the specified item.
Returns true if the tree changes. Throws
an exception if the item is null. All the
item's children are removed also.
|
| Object
|
set (int index[], Object item)
Stores the specified item at the
specified location. Returns the item
previously stored at the location or null if the location is invalid. Throws an exception if the specified item is null.
|
| int
|
size ()
Returns the number of items in this tree.
|
| Object[ ]
|
toArray ()
Returns an array containing all the items
in this tree. The items are stored in the
array in preorder.
|
| String
|
toString ()
Returns a string that contains a nested
parenthesized list of the items in this tree.
|
| TreeIterator
|
treeIterator ()
Returns a tree iterator on this tree.
|