All Packages Class Hierarchy This Package Previous Next Index
Class structure.SplayTree
java.lang.Object
|
+----structure.BinarySearchTree
|
+----structure.SplayTree
- public class SplayTree
- extends BinarySearchTree
An implementation of binary search trees, based on a splay operation
by Tarjan et al. An extension of the binary search tree class.
SplayTree()
- Construct an empty search tree.
add(Object)
- Add a value to the splay tree.
contains(Object)
- Determine if a particular comparable value is within the search tree.
elements()
- Construct an inorder traversal of the elements in the splay tree.
get(Object)
- Fetch a reference to the comparable value in the tree.
remove(Object)
- Remove a comparable value from the tree.
toString()
- Construct a string that represents the splay tree.
SplayTree
public SplayTree()
- Construct an empty search tree.
- Postcondition:
- construct a new splay tree
add
public void add(Object val)
- Add a value to the splay tree.
- Postcondition:
- adds a value to the binary search tree.
- Parameters:
- val - The value to be added.
- Overrides:
- add in class BinarySearchTree
contains
public boolean contains(Object val)
- Determine if a particular comparable value is within the search tree.
- Postcondition:
- returns true iff val is a value found within the tree
- Parameters:
- val - The comparable value to be found.
- Returns:
- True iff the comparable value is within the tree.
- Overrides:
- contains in class BinarySearchTree
get
public Object get(Object val)
- Fetch a reference to the comparable value in the tree.
Resulting value may be inspected, but should not be modified in
a way that might change its position within tree.
- Postcondition:
- returns object found in tree, or null
- Parameters:
- val - The value to be sought in tree.
- Returns:
- A reference to the value within the tree.
- Overrides:
- get in class BinarySearchTree
remove
public Object remove(Object val)
- Remove a comparable value from the tree.
- Postcondition:
- removes one instance of val, if found
- Parameters:
- val - The value to be removed.
- Returns:
- The actual value removed.
- Overrides:
- remove in class BinarySearchTree
elements
public Iterator elements()
- Construct an inorder traversal of the elements in the splay tree.
- Postcondition:
- returns iterator that traverses tree nodes in order
- Returns:
- An iterator to traverse the tree.
- Overrides:
- elements in class BinarySearchTree
toString
public String toString()
- Construct a string that represents the splay tree.
- Postcondition:
- returns string representation
- Returns:
- A string representing the tree.
- Overrides:
- toString in class BinarySearchTree
All Packages Class Hierarchy This Package Previous Next Index