5 * $XConsortium: HashTable.hh /main/4 1996/04/21 19:45:12 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.
25 #include <DtMail/ObjectKey.hh>
27 class HashTableImpl : public DtCPlusPlusAllocator {
29 HashTableImpl(int table_size);
30 virtual ~HashTableImpl(void);
32 virtual void * lookup(ObjectKey &);
33 virtual void set(ObjectKey & key, void * value);
34 virtual void * remove(ObjectKey & key);
36 // HP can not support this construct.
37 // UXP/DS can not support this construct either.
39 #if !defined(HPUX) && !defined(__uxp__)
41 #define HASHTABLE_HASFOREACH
43 typedef int (*HashImplIterator)(ObjectKey &, void * value, void * client_data);
44 virtual void forEach(HashImplIterator, void * client_data);
49 struct HashEntry : public DtCPlusPlusAllocator {
55 HashEntry * _hash_table;
59 template <class Object>
60 class HashTable : public DtCPlusPlusAllocator {
62 HashTable(int table_size) : _table(table_size) { }
64 Object lookup(ObjectKey & key) { return( (Object)((long)_table.lookup(key)) ); }
66 void set(ObjectKey & key, Object obj) {
67 _table.set(key, (void *)obj);
70 Object remove(ObjectKey & key) { return( (Object)((long)_table.remove(key)) ); }
72 #if !defined(HPUX) && !defined(__uxp__)
73 typedef int (*HashIterator)(ObjectKey &, Object, void * client_data);
74 void forEach(HashTableImpl::HashImplIterator iterator, void * client_data) {
75 _table.forEach((HashTableImpl::HashImplIterator)iterator, client_data);