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