0029151: GCC 7.1 warnings "this statement may fall through" [-Wimplicit-fallthrough=]
[occt.git] / src / NCollection / NCollection_DefaultHasher.hxx
1 // Created by: Eugene Maltchikov
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef NCollection_DefaultHasher_HeaderFile
16 #define NCollection_DefaultHasher_HeaderFile
17
18 #include <Standard_Integer.hxx>
19 #include <Standard_Boolean.hxx>
20
21 //=======================================================================
22 //function : HashCode_Proxy
23 //purpose  : Function is required to call the global function HashCode.
24 //=======================================================================
25
26 template <class TheKeyType> 
27 inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey, 
28                                         const Standard_Integer Upper)
29 {
30   return HashCode (theKey, Upper);
31 }
32
33 //=======================================================================
34 //function : IsEqual
35 //purpose  : Default implementation of IsEqual via operator ==
36 //=======================================================================
37
38 template <class TheKeyType> 
39 inline Standard_Boolean IsEqual (const TheKeyType& theKey1, 
40                                  const TheKeyType& theKey2)
41 {
42   return theKey1 == theKey2;
43 }
44
45 //=======================================================================
46 //function : IsEqual_Proxy
47 //purpose  : Function is required to call the global function IsEqual.
48 //=======================================================================
49
50 template <class TheKeyType> 
51 inline Standard_Boolean IsEqual_Proxy (const TheKeyType& theKey1, 
52                                        const TheKeyType& theKey2)
53 {
54   return IsEqual (theKey1, theKey2);
55 }
56
57
58 /**
59  * Purpose:     The  DefaultHasher  is a  Hasher  that is used by
60  *              default in NCollection maps. 
61  *              To compute the  hash code of the key  is used the
62  *              global function HashCode.
63  *              To compare two keys is used  the  global function 
64  *              IsEqual.
65 */
66 template <class TheKeyType> class NCollection_DefaultHasher {
67 public:
68   //
69   static Standard_Integer HashCode(const TheKeyType& theKey, 
70                                    const Standard_Integer Upper) {
71     return HashCode_Proxy(theKey, Upper);
72   }
73   //
74   static Standard_Boolean IsEqual(const TheKeyType& theKey1, 
75                                   const TheKeyType& theKey2) {
76     return IsEqual_Proxy(theKey1, theKey2);
77   }
78 };
79
80 #endif