ReactOS  0.4.13-dev-66-gc714b7f
_hash_fun.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1996-1998
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Permission to use, copy, modify, distribute and sell this software
6  * and its documentation for any purpose is hereby granted without fee,
7  * provided that the above copyright notice appear in all copies and
8  * that both that copyright notice and this permission notice appear
9  * in supporting documentation. Silicon Graphics makes no
10  * representations about the suitability of this software for any
11  * purpose. It is provided "as is" without express or implied warranty.
12  *
13  *
14  * Copyright (c) 1994
15  * Hewlett-Packard Company
16  *
17  * Permission to use, copy, modify, distribute and sell this software
18  * and its documentation for any purpose is hereby granted without fee,
19  * provided that the above copyright notice appear in all copies and
20  * that both that copyright notice and this permission notice appear
21  * in supporting documentation. Hewlett-Packard Company makes no
22  * representations about the suitability of this software for any
23  * purpose. It is provided "as is" without express or implied warranty.
24  *
25  */
26 
27 /* NOTE: This is an internal header file, included by other STL headers.
28  * You should not attempt to use it directly.
29  */
30 
31 #ifndef _STLP_HASH_FUN_H
32 #define _STLP_HASH_FUN_H
33 
34 #ifndef _STLP_INTERNAL_CSTDDEF
35 # include <stl/_cstddef.h>
36 #endif
37 
39 
40 template <class _Key> struct hash { };
41 
43 
44 inline size_t __stl_hash_string(const char* __s) {
46  unsigned long __h = 0;
47  for ( ; *__s; ++__s)
48  __h = 5*__h + *__s;
49 
50  return size_t(__h);
51 }
52 
54 
56 struct hash<char*> {
57  size_t operator()(const char* __s) const {
59  return _STLP_PRIV __stl_hash_string(__s);
60  }
61 };
62 
64 struct hash<const char*> {
65  size_t operator()(const char* __s) const {
67  return _STLP_PRIV __stl_hash_string(__s);
68  }
69 };
70 
72  size_t operator()(char __x) const { return __x; }
73 };
74 _STLP_TEMPLATE_NULL struct hash<unsigned char> {
75  size_t operator()(unsigned char __x) const { return __x; }
76 };
77 #if !defined (_STLP_NO_SIGNED_BUILTINS)
79  size_t operator()(unsigned char __x) const { return __x; }
80 };
81 #endif
83  size_t operator()(short __x) const { return __x; }
84 };
85 _STLP_TEMPLATE_NULL struct hash<unsigned short> {
86  size_t operator()(unsigned short __x) const { return __x; }
87 };
89  size_t operator()(int __x) const { return __x; }
90 };
91 
92 #if !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) || defined (_WIN64)
93 _STLP_TEMPLATE_NULL struct hash<unsigned int> {
94  size_t operator()(unsigned int __x) const { return __x; }
95 };
96 #else
97 /* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef
98  * like size_t are tagged as potential 64 bits variables making them different from
99  * unsigned int. To avoid the warning when a hash container is instanciated with
100  * the size_t key we prefer to grant the size_t specialization rather than the
101  * unsigned int one.
102  */
104  size_t operator()(size_t __x) const { return __x; }
105 };
106 #endif
107 
109  size_t operator()(long __x) const { return __x; }
110 };
111 _STLP_TEMPLATE_NULL struct hash<unsigned long> {
112  size_t operator()(unsigned long __x) const { return __x; }
113 };
114 
115 #if defined (_STLP_LONG_LONG)
117  size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; }
118 };
119 _STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
120  size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; }
121 };
122 #endif
123 
125 struct hash<void *>
126 {
127  union __vp {
128  size_t s;
129  void *p;
130  };
131 
132  size_t operator()(void *__x) const
133  {
134  __vp vp;
135  vp.p = __x;
136  return vp.s;
137  }
138 };
139 
141 
142 #endif /* _STLP_HASH_FUN_H */
143 
144 // Local Variables:
145 // mode:C++
146 // End:
size_t operator()(unsigned long __x) const
Definition: _hash_fun.h:112
size_t operator()(void *__x) const
Definition: _hash_fun.h:132
size_t operator()(short __x) const
Definition: _hash_fun.h:83
size_t operator()(unsigned char __x) const
Definition: _hash_fun.h:75
size_t operator()(const char *__s) const
Definition: _hash_fun.h:57
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define signed
Definition: prototyp.h:114
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
size_t operator()(long __x) const
Definition: _hash_fun.h:109
unsigned char
Definition: typeof.h:29
#define _STLP_LONG_LONG
Definition: _apcc.h:12
__kernel_size_t size_t
Definition: linux.h:237
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
unsigned long
Definition: typeof.h:101
size_t operator()(unsigned char __x) const
Definition: _hash_fun.h:79
_STLP_MOVE_TO_PRIV_NAMESPACE size_t __stl_hash_string(const char *__s)
Definition: _hash_fun.h:44
size_t operator()(unsigned short __x) const
Definition: _hash_fun.h:86
size_t operator()(const char *__s) const
Definition: _hash_fun.h:65
#define _STLP_PRIV
Definition: _dm.h:70
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
size_t operator()(unsigned int __x) const
Definition: _hash_fun.h:94
size_t operator()(char __x) const
Definition: _hash_fun.h:72
#define _STLP_END_NAMESPACE
Definition: features.h:503
size_t operator()(int __x) const
Definition: _hash_fun.h:89
#define _STLP_FIX_LITERAL_BUG(__x)
Definition: features.h:301
#define const
Definition: zconf.h:230
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
Definition: _hash_fun.h:40
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31