Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

6.6 Dictionary Classes

Classes BTreeDictionary, HashDictionary, and IdentityDictionary extend java.util.Dictionary. Sometimes referred to as maps, dictionaries use an external key to find a value. The key and value may be of different types, and in fact usually are. You can think of dictionaries as associating a given key with a given value. For example, if you were building a stock table, you might use the symbol as the key, and its current price as the value.

6.6.1 BTreeDictionary

Class BTreeDictionary is a dictionary class implemented as a B-tree, allowing for the storage and retrieval of key-value pairs. It 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 supplied when the tree is constructed.

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

6.6.2 HashDictionary

Class HashDictionary extends java.util.Hashtable to add additional member functions consistent with the other jtools library dictionary classes. Equality of keys is determined using the equals() method.

6.6.3 IdentityDictionary

Class IdentityDictionary, which inherits from HashDictionary, compares keys on the basis of identity instead of value. In other words, it tests using ==, not equals().


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.