1 // Created by: Eugene Maltchikov
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef NCollection_DefaultHasher_HeaderFile
16 #define NCollection_DefaultHasher_HeaderFile
18 #include <Standard_Integer.hxx>
19 #include <Standard_Boolean.hxx>
21 //=======================================================================
22 //function : HashCode_Proxy
23 //purpose : Function is required to call the global function HashCode.
24 //=======================================================================
26 template <class TheKeyType>
27 inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey,
28 const Standard_Integer Upper)
30 return HashCode (theKey, Upper);
33 //=======================================================================
35 //purpose : Default implementation of IsEqual via operator ==
36 //=======================================================================
38 template <class TheKeyType>
39 inline Standard_Boolean IsEqual (const TheKeyType& theKey1,
40 const TheKeyType& theKey2)
42 return theKey1 == theKey2;
45 //=======================================================================
46 //function : IsEqual_Proxy
47 //purpose : Function is required to call the global function IsEqual.
48 //=======================================================================
50 template <class TheKeyType>
51 inline Standard_Boolean IsEqual_Proxy (const TheKeyType& theKey1,
52 const TheKeyType& theKey2)
54 return IsEqual (theKey1, theKey2);
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
66 template <class TheKeyType> class NCollection_DefaultHasher {
69 static Standard_Integer HashCode(const TheKeyType& theKey,
70 const Standard_Integer Upper) {
71 return HashCode_Proxy(theKey, Upper);
74 static Standard_Boolean IsEqual(const TheKeyType& theKey1,
75 const TheKeyType& theKey2) {
76 return IsEqual_Proxy(theKey1, theKey2);