Source of Listing18-4.h


  1: //  Created by Frank M. Carrano and Timothy M. Henry.
  2: //  Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.

  4: // Listing 18-4.

  6: /** A binary search tree implementation of the ADT dictionary
  7:  that organizes its entries in sorted search-key order.
  8:  Search keys in the dictionary are unique.
  9:  @file TreeDictionary.h */
 10:  
 11: #ifndef TREE_DICTIONARY_
 12: #define TREE_DICTIONARY_

 14: #include "DictionaryInterface.h"
 15: #include "BinarySearchTree.h"
 16: #include "Entry.h"
 17: #include "NotFoundException.h"
 18: #include "PrecondViolatedExcept.h"

 20: template <class KeyType, class ValueType>
 21: class TreeDictionary : public DictionaryInterface<KeyType, ValueType>
 22: {
 23: private:
 24:    // Binary search tree of dictionary entries
 25:    BinarySearchTree<Entry<KeyType, ValueType> > entryTree;
 26:    
 27: public:
 28:    TreeDictionary();
 29:    TreeDictionary(const TreeDictionary<KeyType, ValueType>& dictionary);
 30:    virtual ~TreeDictionary();
 31:    
 32:    // The declarations of the public methods appear here and are the
 33:    // same as given in Listing 18-3 for the class ArrayDictionary.

 35: }; // end TreeDictionary
 36: #include "TreeDictionary.cpp"
 37: #endif