Salome HOME
Get relevant changes from V7_dev branch (copyright update, adm files etc)
[tools/medcoupling.git] / src / INTERP_KERNEL / Bases / InterpKernelHashFun.hxx
1 // Copyright (C) 2001-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // This library is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 // GNU General Public License for more details.
24
25 // Under Section 7 of GPL version 3, you are granted additional
26 // permissions described in the GCC Runtime Library Exception, version
27 // 3.1, as published by the Free Software Foundation.
28
29 // You should have received a copy of the GNU General Public License and
30 // a copy of the GCC Runtime Library Exception along with this program;
31 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
32 // <http://www.gnu.org/licenses/>.
33
34 /*
35  * Copyright (c) 1996-1998
36  * Silicon Graphics Computer Systems, Inc.
37  *
38  * Permission to use, copy, modify, distribute and sell this software
39  * and its documentation for any purpose is hereby granted without fee,
40  * provided that the above copyright notice appear in all copies and
41  * that both that copyright notice and this permission notice appear
42  * in supporting documentation.  Silicon Graphics makes no
43  * representations about the suitability of this software for any
44  * purpose.  It is provided "as is" without express or implied warranty.
45  *
46  *
47  * Copyright (c) 1994
48  * Hewlett-Packard Company
49  *
50  * Permission to use, copy, modify, distribute and sell this software
51  * and its documentation for any purpose is hereby granted without fee,
52  * provided that the above copyright notice appear in all copies and
53  * that both that copyright notice and this permission notice appear
54  * in supporting documentation.  Hewlett-Packard Company makes no
55  * representations about the suitability of this software for any
56  * purpose.  It is provided "as is" without express or implied warranty.
57  *
58  */
59 #ifndef __INTERPKERNELHASHFUN_HXX__
60 #define __INTERPKERNELHASHFUN_HXX__
61
62 #include <cstddef>
63
64 namespace INTERP_KERNEL
65 {
66   template<class _Key>
67   struct hash { };
68
69   inline std::size_t __stl_hash_string(const char* __s)
70   {
71     unsigned long __h = 0;
72     for ( ; *__s; ++__s)
73       __h = 5 * __h + *__s;
74     return std::size_t(__h);
75   }
76
77   template<>
78   struct hash<char*>
79   {
80     std::size_t operator()(const char* __s) const
81     { return __stl_hash_string(__s); }
82   };
83
84   template<>
85   struct hash<const char*>
86   {
87     std::size_t operator()(const char* __s) const
88     { return __stl_hash_string(__s); }
89   };
90
91   template<>
92   struct hash<char>
93   { 
94     std::size_t operator()(char __x) const { return __x; }
95   };
96
97   template<>
98   struct hash<unsigned char>
99   { 
100     std::size_t operator()(unsigned char __x) const { return __x; }
101   };
102
103   template<>
104   struct hash<signed char>
105   {
106     std::size_t operator()(unsigned char __x) const { return __x; }
107   };
108
109   template<>
110   struct hash<short>
111   {
112     std::size_t operator()(short __x) const { return __x; }
113   };
114
115   template<>
116   struct hash<unsigned short>
117   {
118     std::size_t operator()(unsigned short __x) const { return __x; }
119   };
120
121   template<>
122   struct hash<int>
123   { 
124     std::size_t operator()(int __x) const { return __x; }
125   };
126
127   template<>
128   struct hash<unsigned int>
129   { 
130     std::size_t operator()(unsigned int __x) const { return __x; }
131   };
132
133   template<>
134   struct hash<long>
135   {
136     std::size_t operator()(long __x) const { return __x; }
137   };
138
139   template<>
140   struct hash<unsigned long>
141   {
142     std::size_t operator()(unsigned long __x) const { return __x; }
143   };
144 }
145
146 #endif