epoc32/include/tools/stlport/stl/_hash_fun.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_hash_fun.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,146 @@
     1.4 +/*
     1.5 + * Copyright (c) 1996-1998
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Permission to use, copy, modify, distribute and sell this software
     1.9 + * and its documentation for any purpose is hereby granted without fee,
    1.10 + * provided that the above copyright notice appear in all copies and
    1.11 + * that both that copyright notice and this permission notice appear
    1.12 + * in supporting documentation.  Silicon Graphics makes no
    1.13 + * representations about the suitability of this software for any
    1.14 + * purpose.  It is provided "as is" without express or implied warranty.
    1.15 + *
    1.16 + *
    1.17 + * Copyright (c) 1994
    1.18 + * Hewlett-Packard Company
    1.19 + *
    1.20 + * Permission to use, copy, modify, distribute and sell this software
    1.21 + * and its documentation for any purpose is hereby granted without fee,
    1.22 + * provided that the above copyright notice appear in all copies and
    1.23 + * that both that copyright notice and this permission notice appear
    1.24 + * in supporting documentation.  Hewlett-Packard Company makes no
    1.25 + * representations about the suitability of this software for any
    1.26 + * purpose.  It is provided "as is" without express or implied warranty.
    1.27 + *
    1.28 + */
    1.29 +
    1.30 +/* NOTE: This is an internal header file, included by other STL headers.
    1.31 + *   You should not attempt to use it directly.
    1.32 + */
    1.33 +
    1.34 +#ifndef _STLP_HASH_FUN_H
    1.35 +#define _STLP_HASH_FUN_H
    1.36 +
    1.37 +#ifndef _STLP_INTERNAL_CSTDDEF
    1.38 +#  include <stl/_cstddef.h>
    1.39 +#endif
    1.40 +
    1.41 +_STLP_BEGIN_NAMESPACE
    1.42 +
    1.43 +template <class _Key> struct hash { };
    1.44 +
    1.45 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.46 +
    1.47 +inline size_t __stl_hash_string(const char* __s) {
    1.48 +  _STLP_FIX_LITERAL_BUG(__s)
    1.49 +  unsigned long __h = 0;
    1.50 +  for ( ; *__s; ++__s)
    1.51 +    __h = 5*__h + *__s;
    1.52 +
    1.53 +  return size_t(__h);
    1.54 +}
    1.55 +
    1.56 +_STLP_MOVE_TO_STD_NAMESPACE
    1.57 +
    1.58 +_STLP_TEMPLATE_NULL
    1.59 +struct hash<char*> {
    1.60 +  size_t operator()(const char* __s) const {
    1.61 +    _STLP_FIX_LITERAL_BUG(__s)
    1.62 +    return _STLP_PRIV __stl_hash_string(__s);
    1.63 +  }
    1.64 +};
    1.65 +
    1.66 +_STLP_TEMPLATE_NULL
    1.67 +struct hash<const char*> {
    1.68 +  size_t operator()(const char* __s) const {
    1.69 +    _STLP_FIX_LITERAL_BUG(__s)
    1.70 +    return _STLP_PRIV __stl_hash_string(__s);
    1.71 +  }
    1.72 +};
    1.73 +
    1.74 +_STLP_TEMPLATE_NULL struct hash<char> {
    1.75 +  size_t operator()(char __x) const { return __x; }
    1.76 +};
    1.77 +_STLP_TEMPLATE_NULL struct hash<unsigned char> {
    1.78 +  size_t operator()(unsigned char __x) const { return __x; }
    1.79 +};
    1.80 +#if !defined (_STLP_NO_SIGNED_BUILTINS)
    1.81 +_STLP_TEMPLATE_NULL struct hash<signed char> {
    1.82 +  size_t operator()(unsigned char __x) const { return __x; }
    1.83 +};
    1.84 +#endif
    1.85 +_STLP_TEMPLATE_NULL struct hash<short> {
    1.86 +  size_t operator()(short __x) const { return __x; }
    1.87 +};
    1.88 +_STLP_TEMPLATE_NULL struct hash<unsigned short> {
    1.89 +  size_t operator()(unsigned short __x) const { return __x; }
    1.90 +};
    1.91 +_STLP_TEMPLATE_NULL struct hash<int> {
    1.92 +  size_t operator()(int __x) const { return __x; }
    1.93 +};
    1.94 +
    1.95 +#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300)
    1.96 +_STLP_TEMPLATE_NULL struct hash<unsigned int> {
    1.97 +  size_t operator()(unsigned int __x) const { return __x; }
    1.98 +};
    1.99 +#else
   1.100 +/* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef
   1.101 + * like size_t are tagged as potential 64 bits variables making them different from
   1.102 + * unsigned int. To avoid the warning when a hash container is instanciated with
   1.103 + * the size_t key we prefer to grant the size_t specialization rather than the
   1.104 + * unsigned int one.
   1.105 + */
   1.106 +_STLP_TEMPLATE_NULL struct hash<size_t> {
   1.107 +  size_t operator()(size_t __x) const { return __x; }
   1.108 +};
   1.109 +#endif
   1.110 +
   1.111 +_STLP_TEMPLATE_NULL struct hash<long> {
   1.112 +  size_t operator()(long __x) const { return __x; }
   1.113 +};
   1.114 +_STLP_TEMPLATE_NULL struct hash<unsigned long> {
   1.115 +  size_t operator()(unsigned long __x) const { return __x; }
   1.116 +};
   1.117 +
   1.118 +#if defined (_STLP_LONG_LONG)
   1.119 +_STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
   1.120 +  size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; }
   1.121 +};
   1.122 +_STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
   1.123 +  size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; }
   1.124 +};
   1.125 +#endif
   1.126 +
   1.127 +_STLP_TEMPLATE_NULL
   1.128 +struct hash<void *>
   1.129 +{
   1.130 +    union __vp {
   1.131 +        size_t s;
   1.132 +        void  *p;
   1.133 +    };
   1.134 +
   1.135 +    size_t operator()(void *__x) const
   1.136 +      {
   1.137 +        __vp vp;
   1.138 +        vp.p = __x;
   1.139 +        return vp.s;
   1.140 +      }
   1.141 +};
   1.142 +
   1.143 +_STLP_END_NAMESPACE
   1.144 +
   1.145 +#endif /* _STLP_HASH_FUN_H */
   1.146 +
   1.147 +// Local Variables:
   1.148 +// mode:C++
   1.149 +// End: