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
-
btree_
- The underlying BTree of Associations.
-
BTreeDictionary()
- Creates an empty BTreeDictionary with a null comparator.
-
BTreeDictionary(Comparator)
- Creates an empty BTreeDictionary.
-
apply(BinaryFunction)
- Applies the specified function to each key and value pair in the
tree.
-
clear()
- Removes all items from the collection.
-
clone()
- Returns a clone of this BTreeDictionary.
-
contains(Object)
- Searches the BTreeDictionary for a value that
compares equal to the given item.
-
containsKey(Object)
- Checks the BTreeDictionary for a key that
compares equal to the given item.
-
elements()
- Returns an Enumeration object of the values
in this BTreeDictionary, which can be used to visit each value
in turn.
-
find(Object)
- Searches the BTreeDictionary for a value matching
the given item.
-
findKey(Object)
- Searches the BTreeDictionary for a key matching
the given item.
-
get(Object)
- Find in this BTreeDictionary the key comparing
equal to the given item and return its corresponding value.
-
height()
- Calculates the height of this BTreeDictionary by finding
the length of the longest path from the root node to a leaf.
-
isEmpty()
- Returns true if the collection is empty, false otherwise.
-
keys()
- Returns an Enumeration object of the keys
(not the values) in this dictionary, which can be used to visit
each key in turn.
-
occurrencesOf(Object)
- Returns the number of keys in the BTreeDictionary
that compare equal to the given item.
-
put(Object, Object)
- Inserts a key and value association into the BTreeDictionary.
-
remove(Object)
- Removes the key and value pair for which the key compares equal to
the given item.
-
removeAll(Object)
- Removes from the BTreeDictionary all elements that
compare equal to the given item.
-
setComparator(Comparator)
- Set the Comparator.
-
size()
- Returns the number of elements in the collection.
-
subsetOf(BTreeDictionary)
- Returns true if self is a subset of the given BTreeDictionary.
-
toString()
- Converts this BTreeDictionary to a string.
btree_
protected BTree btree_
- The underlying BTree of Associations.
BTreeDictionary
public BTreeDictionary()
- Creates an empty BTreeDictionary with a null comparator.
The comparator must be set before adding any elements.
- See Also:
- setComparator
BTreeDictionary
public BTreeDictionary(Comparator comp)
- Creates an empty BTreeDictionary.
- Parameters:
- comp - The object used to order the elements
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
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
clear
public synchronized void clear()
- Removes all items from the collection.
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
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
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
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
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
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
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
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
isEmpty
public boolean isEmpty()
- Returns true if the collection is empty, false otherwise.
- Overrides:
- isEmpty in class Dictionary
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)
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
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
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)
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.
size
public int size()
- Returns the number of elements in the collection.
- Overrides:
- size in class Dictionary
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.
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