9991c9c2 |
1 | // File: NCollection_DefaultHasher.hxx |
2 | // Created: |
3 | // Author: Eugene Maltchikov |
4 | // |
5 | |
6 | |
7 | #ifndef NCollection_DefaultHasher_HeaderFile |
8 | #define NCollection_DefaultHasher_HeaderFile |
9 | |
10 | #include <Standard_Integer.hxx> |
11 | #include <Standard_Boolean.hxx> |
12 | |
13 | //======================================================================= |
14 | //function : HashCode_Proxy |
15 | //purpose : Function is required to call the global function HashCode. |
16 | //======================================================================= |
17 | template <class TheKeyType> |
18 | static Standard_Integer HashCode_Proxy(const TheKeyType& theKey, |
19 | const Standard_Integer Upper) { |
20 | return HashCode(theKey, Upper); |
21 | } |
22 | |
23 | //======================================================================= |
24 | //function : IsEqual_Proxy |
25 | //purpose : Function is required to call the global function IsEqual. |
26 | //======================================================================= |
27 | template <class TheKeyType> |
28 | static Standard_Boolean IsEqual_Proxy(const TheKeyType& theKey1, |
29 | const TheKeyType& theKey2) { |
30 | return IsEqual(theKey1, theKey2); |
31 | } |
32 | |
33 | |
34 | /** |
35 | * Purpose: The DefaultHasher is a Hasher that is used by |
36 | * default in NCollection maps. |
37 | * To compute the hash code of the key is used the |
38 | * global function HashCode. |
39 | * To compare two keys is used the global function |
40 | * IsEqual. |
41 | */ |
42 | template <class TheKeyType> class NCollection_DefaultHasher { |
43 | public: |
44 | // |
45 | static Standard_Integer HashCode(const TheKeyType& theKey, |
46 | const Standard_Integer Upper) { |
47 | return HashCode_Proxy(theKey, Upper); |
48 | } |
49 | // |
50 | static Standard_Boolean IsEqual(const TheKeyType& theKey1, |
51 | const TheKeyType& theKey2) { |
52 | return IsEqual_Proxy(theKey1, theKey2); |
53 | } |
54 | }; |
55 | |
56 | #endif |