|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.icl.saxon.sort.BinaryTree
A Binary Tree used for sorting. Similar to the java.util.Dictionary interface except (a) that the keys must be Strings rather than general Objects (b) the results are returned as a Vector, not an Enumeration.
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.
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() |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BinaryTree()
Method Detail |
public void setAscending(boolean ascending)
ascending
- true indicates ascending order; false indicates descendingpublic void setDuplicatesAllowed(boolean allow)
public void setComparer(Comparer c)
public Vector getValues()
public Vector getKeys()
public Object get(Object key)
key
- The key value being sought
public boolean isEmpty()
public Object put(Object key, Object value)
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.
public Object remove(Object key)
key
- identifies the entry to be removed
public int size()
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |