All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.tools.v2-0.BTreeDictionary

java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----com.roguewave.tools.v2-0.BTreeDictionary

public class BTreeDictionary
extends Dictionary
implements Cloneable, Serializable
Class BTreeDictionary extends the abstract base class Dictionary from java.util to provide an always balanced tree of keys and associated values. The keys must be unique but the values need not be. The elements are ordered, by key, according to a Comparator, which is supplied when constructing the tree.

Like class BTree, BTreeDictionary is well suited for efficient retrieval from among a large number of elements.

See Also:
BTree, Comparator, NumericCompare, StringCompare

Variable Index

 o btree_
The underlying BTree of Associations.

Constructor Index

 o BTreeDictionary()
Creates an empty BTreeDictionary with a null comparator.
 o BTreeDictionary(Comparator)
Creates an empty BTreeDictionary.

Method Index

 o apply(BinaryFunction)
Applies the specified function to each key and value pair in the tree.
 o clear()
Removes all items from the collection.
 o clone()
Returns a clone of this BTreeDictionary.
 o contains(Object)
Searches the BTreeDictionary for a value that compares equal to the given item.
 o containsKey(Object)
Checks the BTreeDictionary for a key that compares equal to the given item.
 o elements()
Returns an Enumeration object of the values in this BTreeDictionary, which can be used to visit each value in turn.
 o find(Object)
Searches the BTreeDictionary for a value matching the given item.
 o findKey(Object)
Searches the BTreeDictionary for a key matching the given item.
 o get(Object)
Find in this BTreeDictionary the key comparing equal to the given item and return its corresponding value.
 o height()
Calculates the height of this BTreeDictionary by finding the length of the longest path from the root node to a leaf.
 o isEmpty()
Returns true if the collection is empty, false otherwise.
 o keys()
Returns an Enumeration object of the keys (not the values) in this dictionary, which can be used to visit each key in turn.
 o occurrencesOf(Object)
Returns the number of keys in the BTreeDictionary that compare equal to the given item.
 o put(Object, Object)
Inserts a key and value association into the BTreeDictionary.
 o remove(Object)
Removes the key and value pair for which the key compares equal to the given item.
 o removeAll(Object)
Removes from the BTreeDictionary all elements that compare equal to the given item.
 o setComparator(Comparator)
Set the Comparator.
 o size()
Returns the number of elements in the collection.
 o subsetOf(BTreeDictionary)
Returns true if self is a subset of the given BTreeDictionary.
 o toString()
Converts this BTreeDictionary to a string.

Variables

 o btree_
 protected BTree btree_
The underlying BTree of Associations.

Constructors

 o BTreeDictionary
 public BTreeDictionary()
Creates an empty BTreeDictionary with a null comparator. The comparator must be set before adding any elements.

See Also:
setComparator
 o BTreeDictionary
 public BTreeDictionary(Comparator comp)
Creates an empty BTreeDictionary.

Parameters:
comp - The object used to order the elements

Methods

 o height
 public synchronized int height()
Calculates the height of this BTreeDictionary by finding the length of the longest path from the root node to a leaf. Note that an empty tree has height 0, while a tree with only a root with no children has height 1.

Returns:
The height of this BTreeDictionary
 o apply
 public synchronized void apply(BinaryFunction b)
Applies the specified function to each key and value pair in the tree. Note that the return value of the binary function is ignored.

Parameters:
b - The BinaryFunction which will be applied to each key and value pair
 o clear
 public synchronized void clear()
Removes all items from the collection.

 o clone
 public synchronized Object clone()
Returns a clone of this BTreeDictionary. Note that neither the Comparator object nor the elements of the tree themselves are cloned. The cloned tree will have the same node structure as the original tree.

Returns:
The new BTreeDictionary.
Overrides:
clone in class Object
 o contains
 public synchronized boolean contains(Object val)
Searches the BTreeDictionary for a value that compares equal to the given item.

Parameters:
val - The item to be will be tested against the values in the collection.
Returns:
true if a matching value is found, false otherwise
 o containsKey
 public synchronized boolean containsKey(Object key)
Checks the BTreeDictionary for a key that compares equal to the given item.

Parameters:
key - The item to be will be tested against the keys in the collection.
Returns:
true if a matching key is found, false otherwise
Throws: NullPointerException
if key is null
 o elements
 public synchronized Enumeration elements()
Returns an Enumeration object of the values in this BTreeDictionary, which can be used to visit each value in turn.

Returns:
An Enumeration of the values in the collection (not the keys)
Overrides:
elements in class Dictionary
 o find
 public Object find(Object val)
Searches the BTreeDictionary for a value matching the given item.

Parameters:
val - The item to be tested against the values in the collection.
Returns:
The matching value if a match is found, null otherwise
 o findKey
 public synchronized Object findKey(Object key)
Searches the BTreeDictionary for a key matching the given item.

Parameters:
key - The item to be tested against the keys in the collection.
Returns:
The matching key if a match is found, null otherwise
 o get
 public synchronized Object get(Object key)
Find in this BTreeDictionary the key comparing equal to the given item and return its corresponding value.

Parameters:
key - The item to be tested against the keys in the collection.
Returns:
The value associated with the matched key, or null if no match
Overrides:
get in class Dictionary
 o keys
 public synchronized Enumeration keys()
Returns an Enumeration object of the keys (not the values) in this dictionary, which can be used to visit each key in turn.

Returns:
An Enumeration of the keys in this BTreeDictionary
Overrides:
keys in class Dictionary
 o isEmpty
 public boolean isEmpty()
Returns true if the collection is empty, false otherwise.

Overrides:
isEmpty in class Dictionary
 o occurrencesOf
 public int occurrencesOf(Object target)
Returns the number of keys in the BTreeDictionary that compare equal to the given item. Because duplicates are not allowed, this function can only return 0 or 1.

Parameters:
target - The item which is tested against the keys of this collection
Returns:
The number of matches (0 or 1)
 o put
 public synchronized Object put(Object key,
                                Object value)
Inserts a key and value association into the BTreeDictionary. The key and the element cannot be null.

Parameters:
key - The item which will be the key of the association
value - The item which will be the value of the association
Returns:
The old value if the key was already in the BTreeDictionary or null if not and a new association was created
Throws: NullPointerException
if the value is null
Overrides:
put in class Dictionary
 o remove
 public synchronized Object remove(Object target)
Removes the key and value pair for which the key compares equal to the given item.

Parameters:
target - The item to be tested against the keys of the collection
Returns:
The value to which the key had been mapped in this dictionary, or null if the key did not have a mapping
Throws: NullPointerException
if target is null
Overrides:
remove in class Dictionary
 o removeAll
 public int removeAll(Object target)
Removes from the BTreeDictionary all elements that compare equal to the given item. Note that since this collection does not admit duplicate entries, the maximum number of elements removed will be 1.

Parameters:
target - The item to be tested against the keys of the collection
Returns:
The number of elements removed (0 or 1)
 o setComparator
 public boolean setComparator(Comparator comp)
Set the Comparator. The collection must be empty or this method will fail.

Returns:
true if the method is successfull, false otherwise.
 o size
 public int size()
Returns the number of elements in the collection.

Overrides:
size in class Dictionary
 o subsetOf
 public synchronized boolean subsetOf(BTreeDictionary bt)
Returns true if self is a subset of the given BTreeDictionary. Note that an empty tree is a subset of any other tree.

 o toString
 public synchronized String toString()
Converts this BTreeDictionary to a string. The string will have the form
   CompClass:[k1=v1, k2=v2, ... , kN=vN]
 
where CompClass is the string value of the comparator and the keys (k1 - kN) are listed in sorted order along with their corresponding values (v1 - vN).

Returns:
The String representation of this collection.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index