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