blob: 318cb1f97b0202c26364ded10618d9924ffe056f [file] [log] [blame]
Alexis Hunt8d2ed562011-07-29 23:31:56 +00001// -*- C++ -*-
2//===------------------------- hash_set ------------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_EXT_HASH
12#define _LIBCPP_EXT_HASH
13
14#pragma GCC system_header
15
16#include <string>
17#include <cstring>
18
19namespace __gnu_cxx {
20using namespace std;
21
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000022template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
Alexis Hunt8d2ed562011-07-29 23:31:56 +000023
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000024template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
Alexis Hunt8d2ed562011-07-29 23:31:56 +000025 : public unary_function<const char*, size_t>
26{
27 _LIBCPP_INLINE_VISIBILITY
28 size_t operator()(const char *__c) const _NOEXCEPT
29 {
30 return __do_string_hash(__c, __c + strlen(__c));
31 }
32};
33
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000034template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
Alexis Hunt8d2ed562011-07-29 23:31:56 +000035 : public unary_function<char*, size_t>
36{
37 _LIBCPP_INLINE_VISIBILITY
38 size_t operator()(char *__c) const _NOEXCEPT
39 {
40 return __do_string_hash<const char *>(__c, __c + strlen(__c));
41 }
42};
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000043
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000044template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000045 : public unary_function<char, size_t>
46{
47 _LIBCPP_INLINE_VISIBILITY
48 size_t operator()(char __c) const _NOEXCEPT
49 {
50 return __c;
51 }
52};
53
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000054template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000055 : public unary_function<signed char, size_t>
56{
57 _LIBCPP_INLINE_VISIBILITY
58 size_t operator()(signed char __c) const _NOEXCEPT
59 {
60 return __c;
61 }
62};
63
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000064template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000065 : public unary_function<unsigned char, size_t>
66{
67 _LIBCPP_INLINE_VISIBILITY
68 size_t operator()(unsigned char __c) const _NOEXCEPT
69 {
70 return __c;
71 }
72};
73
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000074template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000075 : public unary_function<short, size_t>
76{
77 _LIBCPP_INLINE_VISIBILITY
78 size_t operator()(short __c) const _NOEXCEPT
79 {
80 return __c;
81 }
82};
83
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000084template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000085 : public unary_function<unsigned short, size_t>
86{
87 _LIBCPP_INLINE_VISIBILITY
88 size_t operator()(unsigned short __c) const _NOEXCEPT
89 {
90 return __c;
91 }
92};
93
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +000094template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +000095 : public unary_function<int, size_t>
96{
97 _LIBCPP_INLINE_VISIBILITY
98 size_t operator()(int __c) const _NOEXCEPT
99 {
100 return __c;
101 }
102};
103
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +0000104template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +0000105 : public unary_function<unsigned int, size_t>
106{
107 _LIBCPP_INLINE_VISIBILITY
108 size_t operator()(unsigned int __c) const _NOEXCEPT
109 {
110 return __c;
111 }
112};
113
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +0000114template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +0000115 : public unary_function<long, size_t>
116{
117 _LIBCPP_INLINE_VISIBILITY
118 size_t operator()(long __c) const _NOEXCEPT
119 {
120 return __c;
121 }
122};
123
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +0000124template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
Peter Collingbourne8845dbd2014-03-06 04:11:10 +0000125 : public unary_function<unsigned long, size_t>
126{
127 _LIBCPP_INLINE_VISIBILITY
128 size_t operator()(unsigned long __c) const _NOEXCEPT
129 {
130 return __c;
131 }
132};
Alexis Hunt8d2ed562011-07-29 23:31:56 +0000133}
134
Howard Hinnant119703f2012-11-06 21:55:44 +0000135#endif // _LIBCPP_EXT_HASH