~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to examples/APG/Containers/Hash_Map_Hash.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- C++ -*- */
2
 
// Hash_Map_Hash.h,v 1.1 2004/01/01 21:01:00 shuston Exp
3
 
 
4
 
#ifndef __HASH_MAP_HASH_H_
5
 
#define __HASH_MAP_HASH_H_
6
 
 
7
 
// Listing 1 code/ch05
8
 
// Key type that we are going to use.
9
 
class KeyType
10
 
{
11
 
public:
12
 
  KeyType () : val_(0) {}
13
 
 
14
 
  KeyType (int i) : val_(i) {}
15
 
 
16
 
  KeyType (const KeyType& kt) { this->val_ = kt.val_; }
17
 
 
18
 
  operator int (void) const { return val_; }
19
 
 
20
 
private:
21
 
  int val_;
22
 
};
23
 
 
24
 
// Specialize the hash functor.
25
 
ACE_TEMPLATE_SPECIALIZATION
26
 
class ACE_Hash<KeyType>
27
 
{
28
 
public:
29
 
  u_long operator() (const KeyType kt) const
30
 
  {
31
 
    int val = kt;
32
 
    return (u_long)val;
33
 
  }
34
 
};
35
 
 
36
 
 
37
 
// Specialize the equality functor.
38
 
ACE_TEMPLATE_SPECIALIZATION
39
 
class ACE_Equal_To<KeyType>
40
 
{
41
 
public:
42
 
  int operator() (const KeyType& kt1,
43
 
                  const KeyType& kt2) const
44
 
  {
45
 
    int val1 = kt1;
46
 
    int val2 = kt2;
47
 
    return (val1 == val2);
48
 
  }
49
 
};
50
 
// Listing 1
51
 
 
52
 
#endif /* __HASH_MAP_HASH_H_ */