2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: cc_hdict.h /main/5 1996/08/21 15:49:02 drk $ */
28 #include "dti_cc/types.h"
29 #include "dti_cc/cc_pvect.h"
30 #include "dti_cc/CC_Slist.h"
35 template <class K, class V>
39 static CC_Boolean f_needRemove;
41 kv_pair(K* k, V* v = 0): f_key(k), f_value(v) {};
44 unsigned int operator==(const kv_pair<K, V>&);
47 ostream& print(ostream&);
48 friend ostream& operator<<(ostream& out, kv_pair<K, V>& kv) {
57 #define DEFAULT_BUCKET_NUM 30
59 template <class K, class V> class hashTableIterator;
61 template <class K, class V> class hashTable
63 //template <class K, class V>
64 //friend class hashTableIterator;
66 friend class hashTableIterator<K, V>;
69 unsigned (*f_hash_func_ptr)(const K&);
70 pointer_vector<CC_TPtrSlist<kv_pair<K, V> > > f_buckets;
74 kv_pair<K, V>* _find(const K* k) const;
77 hashTable(const hashTable <K,V> &);
78 hashTable(unsigned (*)(const K&),
79 size_t init_bucket_num = DEFAULT_BUCKET_NUM
83 void clearAndDestroy();
85 size_t entries() { return f_items; };
87 CC_Boolean contains(const K*) const;
89 V* findValue(const K*) const;
90 K* findKeyAndValue(const K*, V*&) const;
92 void insertKeyAndValue(K*, V*);
97 ostream& print(ostream& out);
99 friend ostream& operator<<(ostream& out, hashTable<K, V>& ht) {
100 return ht.print(out);
106 template <class K, class V>
107 class hashTableIterator
112 kv_pair<K, V>* f_rec;
113 hashTable<K, V>& f_hashTable;
115 CC_Boolean _findNonEmptyBucket();
116 CC_Boolean _findNextRecord();
119 hashTableIterator(hashTable<K, V>&);
120 ~hashTableIterator();
122 CC_Boolean operator++();
127 #ifdef EXPAND_TEMPLATES
128 #include "cc_hdict.C"