epoc32/include/stdapis/stlport/stl/_string_hash.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
 * Copyright (c) 1997-1999
williamr@4
     3
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     4
 *
williamr@4
     5
 * Copyright (c) 1999 
williamr@4
     6
 * Boris Fomitchev
williamr@4
     7
 *
williamr@4
     8
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
     9
 * or implied. Any use is at your own risk.
williamr@4
    10
 *
williamr@4
    11
 * Permission to use or copy this software for any purpose is hereby granted 
williamr@4
    12
 * without fee, provided the above notices are retained on all copies.
williamr@4
    13
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    14
 * provided the above notices are retained, and a notice that the code was
williamr@4
    15
 * modified is included with the above copyright notice.
williamr@4
    16
 *
williamr@4
    17
 */
williamr@4
    18
williamr@4
    19
#ifndef _STLP_STRING_HASH_H
williamr@4
    20
# define _STLP_STRING_HASH_H
williamr@4
    21
williamr@4
    22
#ifndef _STLP_HASH_FUN_H
williamr@4
    23
# include <stl/_hash_fun.h>
williamr@4
    24
#endif
williamr@4
    25
williamr@4
    26
#ifndef _STLP_STRING_H
williamr@4
    27
# include <stl/_string.h>
williamr@4
    28
#endif
williamr@4
    29
williamr@4
    30
_STLP_BEGIN_NAMESPACE
williamr@4
    31
williamr@4
    32
template <class _CharT, class _Traits, class _Alloc>
williamr@4
    33
_STLP_INLINE_LOOP size_t
williamr@4
    34
__stl_string_hash(const basic_string<_CharT,_Traits,_Alloc>& __s) {
williamr@4
    35
  unsigned long __h = 0;
williamr@4
    36
  typedef typename basic_string<_CharT,_Traits,_Alloc>::const_pointer const_ptr;
williamr@4
    37
  size_t __len = __s.size();
williamr@4
    38
  const _CharT* __data = __s.data();
williamr@4
    39
  for ( size_t __i = 0; __i < __len; ++__i)
williamr@4
    40
    __h = 5*__h + __data[__i];
williamr@4
    41
  return size_t(__h);
williamr@4
    42
}
williamr@4
    43
williamr@4
    44
#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
williamr@4
    45
williamr@4
    46
template <class _CharT, class _Traits, class _Alloc>
williamr@4
    47
struct hash<basic_string<_CharT,_Traits,_Alloc> > {
williamr@4
    48
  size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const
williamr@4
    49
    { return __stl_string_hash(__s); }
williamr@4
    50
};
williamr@4
    51
williamr@4
    52
#else
williamr@4
    53
williamr@4
    54
_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC hash<string> {
williamr@4
    55
  size_t operator()(const string& __s) const
williamr@4
    56
    { return __stl_string_hash(__s); }
williamr@4
    57
};
williamr@4
    58
williamr@4
    59
# if defined (_STLP_HAS_WCHAR_T)
williamr@4
    60
_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC hash<wstring> {
williamr@4
    61
  size_t operator()(const wstring& __s) const
williamr@4
    62
    { return __stl_string_hash(__s); }
williamr@4
    63
};
williamr@4
    64
# endif
williamr@4
    65
williamr@4
    66
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
williamr@4
    67
williamr@4
    68
_STLP_END_NAMESPACE
williamr@4
    69
williamr@4
    70
#endif