Home | History | Annotate | Line # | Download | only in ext
      1  1.1  joerg // -*- C++ -*-
      2  1.1  joerg //===------------------------- hash_set ------------------------------------===//
      3  1.1  joerg //
      4  1.1  joerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
      5  1.1  joerg // See https://llvm.org/LICENSE.txt for license information.
      6  1.1  joerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
      7  1.1  joerg //
      8  1.1  joerg //===----------------------------------------------------------------------===//
      9  1.1  joerg 
     10  1.1  joerg #ifndef _LIBCPP_EXT_HASH
     11  1.1  joerg #define _LIBCPP_EXT_HASH
     12  1.1  joerg 
     13  1.1  joerg #pragma GCC system_header
     14  1.1  joerg 
     15  1.1  joerg #include <string>
     16  1.1  joerg #include <cstring>
     17  1.1  joerg 
     18  1.1  joerg namespace __gnu_cxx {
     19  1.1  joerg 
     20  1.1  joerg template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
     21  1.1  joerg 
     22  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
     23  1.1  joerg  : public std::unary_function<const char*, size_t>
     24  1.1  joerg {
     25  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     26  1.1  joerg     size_t operator()(const char *__c) const _NOEXCEPT
     27  1.1  joerg     {
     28  1.1  joerg         return std::__do_string_hash(__c, __c + strlen(__c));
     29  1.1  joerg     }
     30  1.1  joerg };
     31  1.1  joerg 
     32  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
     33  1.1  joerg  : public std::unary_function<char*, size_t>
     34  1.1  joerg {
     35  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     36  1.1  joerg     size_t operator()(char *__c) const _NOEXCEPT
     37  1.1  joerg     {
     38  1.1  joerg         return std::__do_string_hash<const char *>(__c, __c + strlen(__c));
     39  1.1  joerg     }
     40  1.1  joerg };
     41  1.1  joerg 
     42  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
     43  1.1  joerg  : public std::unary_function<char, size_t>
     44  1.1  joerg {
     45  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     46  1.1  joerg     size_t operator()(char __c) const _NOEXCEPT
     47  1.1  joerg     {
     48  1.1  joerg         return __c;
     49  1.1  joerg     }
     50  1.1  joerg };
     51  1.1  joerg 
     52  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
     53  1.1  joerg  : public std::unary_function<signed char, size_t>
     54  1.1  joerg {
     55  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     56  1.1  joerg     size_t operator()(signed char __c) const _NOEXCEPT
     57  1.1  joerg     {
     58  1.1  joerg         return __c;
     59  1.1  joerg     }
     60  1.1  joerg };
     61  1.1  joerg 
     62  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
     63  1.1  joerg  : public std::unary_function<unsigned char, size_t>
     64  1.1  joerg {
     65  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     66  1.1  joerg     size_t operator()(unsigned char __c) const _NOEXCEPT
     67  1.1  joerg     {
     68  1.1  joerg         return __c;
     69  1.1  joerg     }
     70  1.1  joerg };
     71  1.1  joerg 
     72  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
     73  1.1  joerg  : public std::unary_function<short, size_t>
     74  1.1  joerg {
     75  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     76  1.1  joerg     size_t operator()(short __c) const _NOEXCEPT
     77  1.1  joerg     {
     78  1.1  joerg         return __c;
     79  1.1  joerg     }
     80  1.1  joerg };
     81  1.1  joerg 
     82  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
     83  1.1  joerg  : public std::unary_function<unsigned short, size_t>
     84  1.1  joerg {
     85  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     86  1.1  joerg     size_t operator()(unsigned short __c) const _NOEXCEPT
     87  1.1  joerg     {
     88  1.1  joerg         return __c;
     89  1.1  joerg     }
     90  1.1  joerg };
     91  1.1  joerg 
     92  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
     93  1.1  joerg     : public std::unary_function<int, size_t>
     94  1.1  joerg {
     95  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
     96  1.1  joerg     size_t operator()(int __c) const _NOEXCEPT
     97  1.1  joerg     {
     98  1.1  joerg         return __c;
     99  1.1  joerg     }
    100  1.1  joerg };
    101  1.1  joerg 
    102  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
    103  1.1  joerg     : public std::unary_function<unsigned int, size_t>
    104  1.1  joerg {
    105  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
    106  1.1  joerg     size_t operator()(unsigned int __c) const _NOEXCEPT
    107  1.1  joerg     {
    108  1.1  joerg         return __c;
    109  1.1  joerg     }
    110  1.1  joerg };
    111  1.1  joerg 
    112  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
    113  1.1  joerg     : public std::unary_function<long, size_t>
    114  1.1  joerg {
    115  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
    116  1.1  joerg     size_t operator()(long __c) const _NOEXCEPT
    117  1.1  joerg     {
    118  1.1  joerg         return __c;
    119  1.1  joerg     }
    120  1.1  joerg };
    121  1.1  joerg 
    122  1.1  joerg template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
    123  1.1  joerg     : public std::unary_function<unsigned long, size_t>
    124  1.1  joerg {
    125  1.1  joerg     _LIBCPP_INLINE_VISIBILITY
    126  1.1  joerg     size_t operator()(unsigned long __c) const _NOEXCEPT
    127  1.1  joerg     {
    128  1.1  joerg         return __c;
    129  1.1  joerg     }
    130  1.1  joerg };
    131  1.1  joerg }
    132  1.1  joerg 
    133  1.1  joerg #endif // _LIBCPP_EXT_HASH
    134