Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / APG / Containers / Hash_Map_Hash.h
blob143ef6f25533bdf546e516a2f9d5a10e571ff38c
1 /* -*- C++ -*- */
2 #ifndef __HASH_MAP_HASH_H_
3 #define __HASH_MAP_HASH_H_
5 // Listing 1 code/ch05
6 // Key type that we are going to use.
7 class KeyType
9 public:
10 KeyType () : val_(0) {}
12 KeyType (int i) : val_(i) {}
14 KeyType (const KeyType& kt) { this->val_ = kt.val_; }
16 operator int () const { return val_; }
18 private:
19 int val_;
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 // Specialize the hash functor.
25 template<>
26 class ACE_Hash<KeyType>
28 public:
29 u_long operator() (const KeyType kt) const
31 int val = kt;
32 return (u_long)val;
37 // Specialize the equality functor.
38 template<>
39 class ACE_Equal_To<KeyType>
41 public:
42 int operator() (const KeyType& kt1,
43 const KeyType& kt2) const
45 int val1 = kt1;
46 int val2 = kt2;
47 return (val1 == val2);
51 ACE_END_VERSIONED_NAMESPACE_DECL
53 // Listing 1
55 #endif /* __HASH_MAP_HASH_H_ */