com.icl.saxon.sort
public class BinaryTree extends Object
The methods getKeys() and getValues() return values in ascending order of key. The keys are compared using a default Collator which sorts in alphabetical order with intelligent handling of case and accents.
Note that duplicate keys are not allowed: a new entry silently overwrites any previous entry with the same key. If you want to use dulicate keys, append a unique value (for example, a random number) to each one.
Version: 9 July 1999: now returns a Vector rather than an Enumeration
Constructor Summary | |
---|---|
BinaryTree() |
Method Summary | |
---|---|
Object | get(Object key)
get(String) returns the value corresponding to a given key, if any |
Vector | getKeys()
getKeys() returns the keys in the tree in sorted order. |
Vector | getValues()
getValues() returns the values in the tree in sorted order. |
boolean | isEmpty()
isEmpty()
Tests if this binary tree contains no keys. |
static void | main(String[] args) |
Object | put(Object key, Object value)
put(Object, Object) puts a new entry in the tree, overwriting any previous entry with
the same key. |
Object | remove(Object key)
remove(Object)
removes the key (and its corresponding value) from this Binary Tree.
|
void | setAscending(boolean ascending)
Set order. |
void | setComparer(Comparer c)
Set the Comparer to be used for the keys in this tree.
|
void | setDuplicatesAllowed(boolean allow)
Define whether duplicate keys are allowed or not. |
int | size()
size() |
Parameters: key The key value being sought
Returns: the value to which the key is mapped in this binary tree, or null if there is no entry with this key
Returns: an Vector containing the keys in this BinaryTree (in key order).
Returns: an Vector containing the values in this BinaryTree (in key order).
Returns: true if there are no entries in the tree
Parameters: key The value of the key. Note this must be a String, and must not be null. value The value to be associated with this key. Must not be null.
Returns: the value previously associated with this key, if there was one. Otherwise null.
Parameters: key identifies the entry to be removed
Returns: the value that was associated with this key, if there was one. Otherwise null.
Parameters: ascending true indicates ascending order; false indicates descending
Returns: the number of entries in this binary tree.