5 * $XConsortium: Dictionary.hh /main/4 1996/04/21 19:44:36 drk $
7 * RESTRICTED CONFIDENTIAL INFORMATION:
9 * The information in this document is subject to special
10 * restrictions in a confidential disclosure agreement bertween
11 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
12 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
13 * Sun's specific written approval. This documment and all copies
14 * and derivative works thereof must be returned or destroyed at
17 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
22 #ifndef _DTM_DICTIONARY_HH
23 #define _DTM_DICTIONARY_HH
25 #include "DtVirtArray.hh"
27 class DtMailDictionaryImpl : public DtCPlusPlusAllocator {
29 // The hash_size must be <= 256. Setting to smaller sizes
30 // will reduce the memory used by the dictionary, but may increase
31 // the hash collisions resulting in slower performance.
33 DtMailDictionaryImpl(int hash_size = 256);
34 ~DtMailDictionaryImpl(void);
36 void set(const char * key, const void * value);
37 const void * lookup(const char * key);
38 void remove(const char * key);
41 struct Entry : public DtCPlusPlusAllocator {
46 typedef DtVirtArray<Entry *> * HashTable_t;
48 HashTable_t *_hash_table;
52 int hashValue(const char * key);
53 void locate(int hash_value, const char * key, Entry ** entry);
56 template <class Element>
57 class DtMailDictionary : public DtCPlusPlusAllocator {
59 DtMailDictionary(int hash_size = 256) : _dict(hash_size) { }
60 ~DtMailDictionary(void) { }
62 void set(const char * key, const Element value) { _dict.set(key, value); }
64 const Element lookup(const char * key) {
65 return((const Element)_dict.lookup(key));
68 void remove(const char * key) { _dict.remove(key); }
71 DtMailDictionaryImpl _dict;