ReactOS 0.4.15-dev-7998-gdb93cb1
_string_hash.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1997-1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18
19#ifndef _STLP_STRING_HASH_H
20#define _STLP_STRING_HASH_H
21
22#ifndef _STLP_HASH_FUN_H
23# include <stl/_hash_fun.h>
24#endif
25
26#ifndef _STLP_INTERNAL_STRING_H
27# include <stl/_string.h>
28#endif
29
31
32template <class _CharT, class _Traits, class _Alloc>
35 unsigned long __h = 0;
36 size_t __len = __s.size();
37 const _CharT* __data = __s.data();
38 for ( size_t __i = 0; __i < __len; ++__i)
39 __h = /* 5 *__h */(__h << 2) + __h + __data[__i];
40 return size_t(__h);
41}
42
43#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \
44 (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x560))
45template <class _CharT, class _Traits, class _Alloc>
46struct hash<basic_string<_CharT,_Traits,_Alloc> > {
47 size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const
48 { return __stl_string_hash(__s); }
49};
50
51#else
52
55 size_t operator()(const string& __s) const
56 { return __stl_string_hash(__s); }
57};
58
59# if defined (_STLP_HAS_WCHAR_T)
61struct _STLP_CLASS_DECLSPEC hash<wstring> {
62 size_t operator()(const wstring& __s) const
63 { return __stl_string_hash(__s); }
64};
65# endif
66
67#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
68
70
71#endif
#define _Alloc
Definition: _bvector.h:330
_STLP_BEGIN_NAMESPACE _STLP_INLINE_LOOP size_t __stl_string_hash(const basic_string< _CharT, _Traits, _Alloc > &__s)
Definition: _string_hash.h:34
size_type size() const
Definition: _string.h:400
const _CharT * data() const
Definition: _string.h:950
__kernel_size_t size_t
Definition: linux.h:237
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
#define _STLP_INLINE_LOOP
Definition: features.h:648
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
size_t operator()(const string &__s) const
Definition: _string_hash.h:55
Definition: _hash_fun.h:40