Fix typo in license headers
[oweals/cde.git] / cde / programs / dtmail / include / DtMail / Dictionary.hh
1 /*
2  *+SNOTICE
3  *
4  *
5  *      $XConsortium: Dictionary.hh /main/4 1996/04/21 19:44:36 drk $
6  *
7  *      RESTRICTED CONFIDENTIAL INFORMATION:
8  *      
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
15  *      Sun's request.
16  *
17  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
18  *
19  *+ENOTICE
20  */
21
22 #ifndef _DTM_DICTIONARY_HH
23 #define _DTM_DICTIONARY_HH
24
25 #include "DtVirtArray.hh"
26
27 class DtMailDictionaryImpl : public DtCPlusPlusAllocator {
28   public:
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.
32     //
33     DtMailDictionaryImpl(int hash_size = 256);
34     ~DtMailDictionaryImpl(void);
35
36     void set(const char * key, const void * value);
37     const void * lookup(const char * key);
38     void remove(const char * key);
39
40   private:
41     struct Entry : public DtCPlusPlusAllocator {
42         char *                  key;
43         const void *            value;
44     };
45
46     typedef DtVirtArray<Entry *> * HashTable_t;
47
48     HashTable_t         *_hash_table;
49     int                 _hash_size;
50     void                *_obj_mutex;
51
52     int hashValue(const char * key);
53     void locate(int hash_value, const char * key, Entry ** entry);
54 };
55
56 template <class Element>
57 class DtMailDictionary : public DtCPlusPlusAllocator {
58   public:
59     DtMailDictionary(int hash_size = 256) : _dict(hash_size) { }
60     ~DtMailDictionary(void) { }
61
62     void set(const char * key, const Element value) { _dict.set(key, value); }
63
64     const Element lookup(const char * key) {
65         return((const Element)_dict.lookup(key));
66     }
67
68     void remove(const char * key) { _dict.remove(key); }
69
70   private:
71     DtMailDictionaryImpl        _dict;
72     
73 };
74
75 #endif