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