williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 1996-1998
|
williamr@2
|
3 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* Permission to use, copy, modify, distribute and sell this software
|
williamr@2
|
6 |
* and its documentation for any purpose is hereby granted without fee,
|
williamr@2
|
7 |
* provided that the above copyright notice appear in all copies and
|
williamr@2
|
8 |
* that both that copyright notice and this permission notice appear
|
williamr@2
|
9 |
* in supporting documentation. Silicon Graphics makes no
|
williamr@2
|
10 |
* representations about the suitability of this software for any
|
williamr@2
|
11 |
* purpose. It is provided "as is" without express or implied warranty.
|
williamr@2
|
12 |
*
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Copyright (c) 1994
|
williamr@2
|
15 |
* Hewlett-Packard Company
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
* Permission to use, copy, modify, distribute and sell this software
|
williamr@2
|
18 |
* and its documentation for any purpose is hereby granted without fee,
|
williamr@2
|
19 |
* provided that the above copyright notice appear in all copies and
|
williamr@2
|
20 |
* that both that copyright notice and this permission notice appear
|
williamr@2
|
21 |
* in supporting documentation. Hewlett-Packard Company makes no
|
williamr@2
|
22 |
* representations about the suitability of this software for any
|
williamr@2
|
23 |
* purpose. It is provided "as is" without express or implied warranty.
|
williamr@2
|
24 |
*
|
williamr@2
|
25 |
*/
|
williamr@2
|
26 |
|
williamr@2
|
27 |
/* NOTE: This is an internal header file, included by other STL headers.
|
williamr@2
|
28 |
* You should not attempt to use it directly.
|
williamr@2
|
29 |
*/
|
williamr@2
|
30 |
|
williamr@2
|
31 |
#ifndef _STLP_HASH_FUN_H
|
williamr@2
|
32 |
#define _STLP_HASH_FUN_H
|
williamr@2
|
33 |
|
williamr@2
|
34 |
# ifndef _STLP_CSTDDEF
|
williamr@2
|
35 |
# include <cstddef>
|
williamr@2
|
36 |
# endif
|
williamr@2
|
37 |
|
williamr@2
|
38 |
_STLP_BEGIN_NAMESPACE
|
williamr@2
|
39 |
|
williamr@2
|
40 |
template <class _Key> struct hash { };
|
williamr@2
|
41 |
|
williamr@2
|
42 |
inline size_t __stl_hash_string(const char* __s)
|
williamr@2
|
43 |
{
|
williamr@2
|
44 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
45 |
unsigned long __h = 0;
|
williamr@2
|
46 |
for ( ; *__s; ++__s)
|
williamr@2
|
47 |
__h = 5*__h + *__s;
|
williamr@2
|
48 |
|
williamr@2
|
49 |
return size_t(__h);
|
williamr@2
|
50 |
}
|
williamr@2
|
51 |
|
williamr@2
|
52 |
_STLP_TEMPLATE_NULL struct hash<char*>
|
williamr@2
|
53 |
{
|
williamr@2
|
54 |
size_t operator()(const char* __s) const { _STLP_FIX_LITERAL_BUG(__s) return __stl_hash_string(__s); }
|
williamr@2
|
55 |
};
|
williamr@2
|
56 |
|
williamr@2
|
57 |
_STLP_TEMPLATE_NULL struct hash<const char*>
|
williamr@2
|
58 |
{
|
williamr@2
|
59 |
size_t operator()(const char* __s) const { _STLP_FIX_LITERAL_BUG(__s) return __stl_hash_string(__s); }
|
williamr@2
|
60 |
};
|
williamr@2
|
61 |
|
williamr@2
|
62 |
_STLP_TEMPLATE_NULL struct hash<char> {
|
williamr@2
|
63 |
size_t operator()(char __x) const { return __x; }
|
williamr@2
|
64 |
};
|
williamr@2
|
65 |
_STLP_TEMPLATE_NULL struct hash<unsigned char> {
|
williamr@2
|
66 |
size_t operator()(unsigned char __x) const { return __x; }
|
williamr@2
|
67 |
};
|
williamr@2
|
68 |
#ifndef _STLP_NO_SIGNED_BUILTINS
|
williamr@2
|
69 |
_STLP_TEMPLATE_NULL struct hash<signed char> {
|
williamr@2
|
70 |
size_t operator()(unsigned char __x) const { return __x; }
|
williamr@2
|
71 |
};
|
williamr@2
|
72 |
#endif
|
williamr@2
|
73 |
_STLP_TEMPLATE_NULL struct hash<short> {
|
williamr@2
|
74 |
size_t operator()(short __x) const { return __x; }
|
williamr@2
|
75 |
};
|
williamr@2
|
76 |
_STLP_TEMPLATE_NULL struct hash<unsigned short> {
|
williamr@2
|
77 |
size_t operator()(unsigned short __x) const { return __x; }
|
williamr@2
|
78 |
};
|
williamr@2
|
79 |
_STLP_TEMPLATE_NULL struct hash<int> {
|
williamr@2
|
80 |
size_t operator()(int __x) const { return __x; }
|
williamr@2
|
81 |
};
|
williamr@2
|
82 |
_STLP_TEMPLATE_NULL struct hash<unsigned int> {
|
williamr@2
|
83 |
size_t operator()(unsigned int __x) const { return __x; }
|
williamr@2
|
84 |
};
|
williamr@2
|
85 |
_STLP_TEMPLATE_NULL struct hash<long> {
|
williamr@2
|
86 |
size_t operator()(long __x) const { return __x; }
|
williamr@2
|
87 |
};
|
williamr@2
|
88 |
_STLP_TEMPLATE_NULL struct hash<unsigned long> {
|
williamr@2
|
89 |
size_t operator()(unsigned long __x) const { return __x; }
|
williamr@2
|
90 |
};
|
williamr@2
|
91 |
|
williamr@2
|
92 |
# if defined (_STLP_LONG_LONG)
|
williamr@2
|
93 |
_STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
|
williamr@2
|
94 |
size_t operator()(long x) const { return x; }
|
williamr@2
|
95 |
};
|
williamr@2
|
96 |
_STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
|
williamr@2
|
97 |
size_t operator()(unsigned long x) const { return x; }
|
williamr@2
|
98 |
};
|
williamr@2
|
99 |
# endif
|
williamr@2
|
100 |
|
williamr@2
|
101 |
_STLP_END_NAMESPACE
|
williamr@2
|
102 |
|
williamr@2
|
103 |
#endif /* _STLP_HASH_FUN_H */
|
williamr@2
|
104 |
|
williamr@2
|
105 |
// Local Variables:
|
williamr@2
|
106 |
// mode:C++
|
williamr@2
|
107 |
// End:
|