xref: /aosp_15_r20/external/libcxx/include/ext/__hash (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===------------------------- hash_set ------------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_EXT_HASH
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_EXT_HASH
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
15*58b9f456SAndroid Build Coastguard Worker
16*58b9f456SAndroid Build Coastguard Worker#include <string>
17*58b9f456SAndroid Build Coastguard Worker#include <cstring>
18*58b9f456SAndroid Build Coastguard Worker
19*58b9f456SAndroid Build Coastguard Workernamespace __gnu_cxx {
20*58b9f456SAndroid Build Coastguard Workerusing namespace std;
21*58b9f456SAndroid Build Coastguard Worker
22*58b9f456SAndroid Build Coastguard Workertemplate <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
23*58b9f456SAndroid Build Coastguard Worker
24*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
25*58b9f456SAndroid Build Coastguard Worker    : public unary_function<const char*, size_t>
26*58b9f456SAndroid Build Coastguard Worker{
27*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
28*58b9f456SAndroid Build Coastguard Worker    size_t operator()(const char *__c) const _NOEXCEPT
29*58b9f456SAndroid Build Coastguard Worker    {
30*58b9f456SAndroid Build Coastguard Worker        return __do_string_hash(__c, __c + strlen(__c));
31*58b9f456SAndroid Build Coastguard Worker    }
32*58b9f456SAndroid Build Coastguard Worker};
33*58b9f456SAndroid Build Coastguard Worker
34*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
35*58b9f456SAndroid Build Coastguard Worker    : public unary_function<char*, size_t>
36*58b9f456SAndroid Build Coastguard Worker{
37*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
38*58b9f456SAndroid Build Coastguard Worker    size_t operator()(char *__c) const _NOEXCEPT
39*58b9f456SAndroid Build Coastguard Worker    {
40*58b9f456SAndroid Build Coastguard Worker        return __do_string_hash<const char *>(__c, __c + strlen(__c));
41*58b9f456SAndroid Build Coastguard Worker    }
42*58b9f456SAndroid Build Coastguard Worker};
43*58b9f456SAndroid Build Coastguard Worker
44*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<char>
45*58b9f456SAndroid Build Coastguard Worker    : public unary_function<char, size_t>
46*58b9f456SAndroid Build Coastguard Worker{
47*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
48*58b9f456SAndroid Build Coastguard Worker    size_t operator()(char __c) const _NOEXCEPT
49*58b9f456SAndroid Build Coastguard Worker    {
50*58b9f456SAndroid Build Coastguard Worker        return __c;
51*58b9f456SAndroid Build Coastguard Worker    }
52*58b9f456SAndroid Build Coastguard Worker};
53*58b9f456SAndroid Build Coastguard Worker
54*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
55*58b9f456SAndroid Build Coastguard Worker    : public unary_function<signed char, size_t>
56*58b9f456SAndroid Build Coastguard Worker{
57*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
58*58b9f456SAndroid Build Coastguard Worker    size_t operator()(signed char __c) const _NOEXCEPT
59*58b9f456SAndroid Build Coastguard Worker    {
60*58b9f456SAndroid Build Coastguard Worker        return __c;
61*58b9f456SAndroid Build Coastguard Worker    }
62*58b9f456SAndroid Build Coastguard Worker};
63*58b9f456SAndroid Build Coastguard Worker
64*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
65*58b9f456SAndroid Build Coastguard Worker    : public unary_function<unsigned char, size_t>
66*58b9f456SAndroid Build Coastguard Worker{
67*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
68*58b9f456SAndroid Build Coastguard Worker    size_t operator()(unsigned char __c) const _NOEXCEPT
69*58b9f456SAndroid Build Coastguard Worker    {
70*58b9f456SAndroid Build Coastguard Worker        return __c;
71*58b9f456SAndroid Build Coastguard Worker    }
72*58b9f456SAndroid Build Coastguard Worker};
73*58b9f456SAndroid Build Coastguard Worker
74*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<short>
75*58b9f456SAndroid Build Coastguard Worker    : public unary_function<short, size_t>
76*58b9f456SAndroid Build Coastguard Worker{
77*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
78*58b9f456SAndroid Build Coastguard Worker    size_t operator()(short __c) const _NOEXCEPT
79*58b9f456SAndroid Build Coastguard Worker    {
80*58b9f456SAndroid Build Coastguard Worker        return __c;
81*58b9f456SAndroid Build Coastguard Worker    }
82*58b9f456SAndroid Build Coastguard Worker};
83*58b9f456SAndroid Build Coastguard Worker
84*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
85*58b9f456SAndroid Build Coastguard Worker    : public unary_function<unsigned short, size_t>
86*58b9f456SAndroid Build Coastguard Worker{
87*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
88*58b9f456SAndroid Build Coastguard Worker    size_t operator()(unsigned short __c) const _NOEXCEPT
89*58b9f456SAndroid Build Coastguard Worker    {
90*58b9f456SAndroid Build Coastguard Worker        return __c;
91*58b9f456SAndroid Build Coastguard Worker    }
92*58b9f456SAndroid Build Coastguard Worker};
93*58b9f456SAndroid Build Coastguard Worker
94*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<int>
95*58b9f456SAndroid Build Coastguard Worker    : public unary_function<int, size_t>
96*58b9f456SAndroid Build Coastguard Worker{
97*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
98*58b9f456SAndroid Build Coastguard Worker    size_t operator()(int __c) const _NOEXCEPT
99*58b9f456SAndroid Build Coastguard Worker    {
100*58b9f456SAndroid Build Coastguard Worker        return __c;
101*58b9f456SAndroid Build Coastguard Worker    }
102*58b9f456SAndroid Build Coastguard Worker};
103*58b9f456SAndroid Build Coastguard Worker
104*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
105*58b9f456SAndroid Build Coastguard Worker    : public unary_function<unsigned int, size_t>
106*58b9f456SAndroid Build Coastguard Worker{
107*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
108*58b9f456SAndroid Build Coastguard Worker    size_t operator()(unsigned int __c) const _NOEXCEPT
109*58b9f456SAndroid Build Coastguard Worker    {
110*58b9f456SAndroid Build Coastguard Worker        return __c;
111*58b9f456SAndroid Build Coastguard Worker    }
112*58b9f456SAndroid Build Coastguard Worker};
113*58b9f456SAndroid Build Coastguard Worker
114*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<long>
115*58b9f456SAndroid Build Coastguard Worker    : public unary_function<long, size_t>
116*58b9f456SAndroid Build Coastguard Worker{
117*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
118*58b9f456SAndroid Build Coastguard Worker    size_t operator()(long __c) const _NOEXCEPT
119*58b9f456SAndroid Build Coastguard Worker    {
120*58b9f456SAndroid Build Coastguard Worker        return __c;
121*58b9f456SAndroid Build Coastguard Worker    }
122*58b9f456SAndroid Build Coastguard Worker};
123*58b9f456SAndroid Build Coastguard Worker
124*58b9f456SAndroid Build Coastguard Workertemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
125*58b9f456SAndroid Build Coastguard Worker    : public unary_function<unsigned long, size_t>
126*58b9f456SAndroid Build Coastguard Worker{
127*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
128*58b9f456SAndroid Build Coastguard Worker    size_t operator()(unsigned long __c) const _NOEXCEPT
129*58b9f456SAndroid Build Coastguard Worker    {
130*58b9f456SAndroid Build Coastguard Worker        return __c;
131*58b9f456SAndroid Build Coastguard Worker    }
132*58b9f456SAndroid Build Coastguard Worker};
133*58b9f456SAndroid Build Coastguard Worker}
134*58b9f456SAndroid Build Coastguard Worker
135*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_EXT_HASH
136