STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
hash_fun.h File Reference
#include <bits/c++config.h>

Go to the source code of this file.

Functions

namespace __gnu_cxx _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This file is a GNU extension to the Standard C++ Library (possibly containing extensions from the HP/SGI STL subset).

Function Documentation

namespace __gnu_cxx _GLIBCXX_VISIBILITY ( default  )
62 {
63 _GLIBCXX_BEGIN_NAMESPACE_VERSION
64 
65  using std::size_t;
66 
67  template<class _Key>
68  struct hash { };
69 
70  inline size_t
71  __stl_hash_string(const char* __s)
72  {
73  unsigned long __h = 0;
74  for ( ; *__s; ++__s)
75  __h = 5 * __h + *__s;
76  return size_t(__h);
77  }
78 
79  template<>
80  struct hash<char*>
81  {
82  size_t
83  operator()(const char* __s) const
84  { return __stl_hash_string(__s); }
85  };
86 
87  template<>
88  struct hash<const char*>
89  {
90  size_t
91  operator()(const char* __s) const
92  { return __stl_hash_string(__s); }
93  };
94 
95  template<>
96  struct hash<char>
97  {
98  size_t
99  operator()(char __x) const
100  { return __x; }
101  };
102 
103  template<>
104  struct hash<unsigned char>
105  {
106  size_t
107  operator()(unsigned char __x) const
108  { return __x; }
109  };
110 
111  template<>
112  struct hash<signed char>
113  {
114  size_t
115  operator()(unsigned char __x) const
116  { return __x; }
117  };
118 
119  template<>
120  struct hash<short>
121  {
122  size_t
123  operator()(short __x) const
124  { return __x; }
125  };
126 
127  template<>
128  struct hash<unsigned short>
129  {
130  size_t
131  operator()(unsigned short __x) const
132  { return __x; }
133  };
134 
135  template<>
136  struct hash<int>
137  {
138  size_t
139  operator()(int __x) const
140  { return __x; }
141  };
142 
143  template<>
144  struct hash<unsigned int>
145  {
146  size_t
147  operator()(unsigned int __x) const
148  { return __x; }
149  };
150 
151  template<>
152  struct hash<long>
153  {
154  size_t
155  operator()(long __x) const
156  { return __x; }
157  };
158 
159  template<>
160  struct hash<unsigned long>
161  {
162  size_t
163  operator()(unsigned long __x) const
164  { return __x; }
165  };
166 
167 _GLIBCXX_END_NAMESPACE_VERSION
168 } // namespace
__SIZE_TYPE__ size_t
Definition: stddef.h:212