1 // Copyright (c) 1994 James Clark 2 // See the file COPYING for copying permission. 3 #pragma ident "%Z%%M% %I% %E% SMI" 4 5 #ifndef HashTableItemBase_INCLUDED 6 #define HashTableItemBase_INCLUDED 1 7 8 // All hash tables with the same type of key share object code. 9 // The cost of this is a virtual dtor in HashTableItemBase. 10 11 #ifdef SP_NAMESPACE 12 namespace SP_NAMESPACE { 13 #endif 14 15 template<class K> 16 class HashTableItemBase { 17 public: 18 HashTableItemBase(const K &k); 19 virtual ~HashTableItemBase(); 20 virtual HashTableItemBase<K> *copy() const = 0; 21 K key; 22 }; 23 24 template<class K> 25 struct HashTableKeyFunction { keyHashTableKeyFunction26 static inline const K &key(const HashTableItemBase<K> &obj) { 27 return obj.key; 28 } 29 }; 30 31 #ifdef SP_NAMESPACE 32 } 33 #endif 34 35 #endif /* not HashTableItemBase_INCLUDED */ 36 37 #ifdef SP_DEFINE_TEMPLATES 38 #include "HashTableItemBase.cxx" 39 #endif 40