epoc32/include/stdapis/stlport/stl/_string_hash.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_string_hash.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997-1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999 
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted 
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#ifndef _STLP_STRING_HASH_H
    1.23 +# define _STLP_STRING_HASH_H
    1.24 +
    1.25 +#ifndef _STLP_HASH_FUN_H
    1.26 +# include <stl/_hash_fun.h>
    1.27 +#endif
    1.28 +
    1.29 +#ifndef _STLP_STRING_H
    1.30 +# include <stl/_string.h>
    1.31 +#endif
    1.32 +
    1.33 +_STLP_BEGIN_NAMESPACE
    1.34 +
    1.35 +template <class _CharT, class _Traits, class _Alloc>
    1.36 +_STLP_INLINE_LOOP size_t
    1.37 +__stl_string_hash(const basic_string<_CharT,_Traits,_Alloc>& __s) {
    1.38 +  unsigned long __h = 0;
    1.39 +  typedef typename basic_string<_CharT,_Traits,_Alloc>::const_pointer const_ptr;
    1.40 +  size_t __len = __s.size();
    1.41 +  const _CharT* __data = __s.data();
    1.42 +  for ( size_t __i = 0; __i < __len; ++__i)
    1.43 +    __h = 5*__h + __data[__i];
    1.44 +  return size_t(__h);
    1.45 +}
    1.46 +
    1.47 +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
    1.48 +
    1.49 +template <class _CharT, class _Traits, class _Alloc>
    1.50 +struct hash<basic_string<_CharT,_Traits,_Alloc> > {
    1.51 +  size_t operator()(const basic_string<_CharT,_Traits,_Alloc>& __s) const
    1.52 +    { return __stl_string_hash(__s); }
    1.53 +};
    1.54 +
    1.55 +#else
    1.56 +
    1.57 +_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC hash<string> {
    1.58 +  size_t operator()(const string& __s) const
    1.59 +    { return __stl_string_hash(__s); }
    1.60 +};
    1.61 +
    1.62 +# if defined (_STLP_HAS_WCHAR_T)
    1.63 +_STLP_TEMPLATE_NULL struct _STLP_CLASS_DECLSPEC hash<wstring> {
    1.64 +  size_t operator()(const wstring& __s) const
    1.65 +    { return __stl_string_hash(__s); }
    1.66 +};
    1.67 +# endif
    1.68 +
    1.69 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
    1.70 +
    1.71 +_STLP_END_NAMESPACE
    1.72 +
    1.73 +#endif