-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrde_string.h
More file actions
29 lines (24 loc) · 773 Bytes
/
rde_string.h
File metadata and controls
29 lines (24 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef RDESTL_STRING_H
#define RDESTL_STRING_H
#include "basic_string.h"
#include "rhash.h"
namespace rde
{
typedef basic_string<char> string;
template<typename E, class TAllocator, typename TStorage>
struct hash<basic_string<E, TAllocator, TStorage> >
{
hash_value_t operator()(const basic_string<E, TAllocator, TStorage>& x) const
{
// Derived from: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/142054
hash_value_t h = 0;
for (typename basic_string<E, TAllocator, TStorage>::size_type p = 0; p < x.length(); ++p)
{
h = x[p] + (h<<6) + (h<<16) - h;
}
return h & 0x7FFFFFFF;
}
};
} // namespace rde
//-----------------------------------------------------------------------------
#endif // RDESTL_STRING_H