BagDictionary - Description

The generic class BagDictionary is a balanced binary dictionary. The generic has two type parameters, K - the key type, and T - the data type. BagDictionaries are different from single key dictionaries in that they allow duplicate keys.

When creating a dictionary BagDictionary<K,T>, the key class K is expected to be comparable. There are two ways in which the comparator for class K can be specified:

  1. the class K may derive from Comparable of K or
  2. the constructor BagDictionary - Comparator may be used to manually specify the comparator.

The declaration of the bag dictionary class (in Java) is shown below.

public class BagDictionary<K, T> implements Iterable<KeyValue<K, T>>.

Searches, insertions and removals are O(log2n).

When for is applied to a dictionary, the entries are presented in key order.