__hash revision 278724
1251652Sgjb// -*- C++ -*- 2251652Sgjb//===------------------------- hash_set ------------------------------------===// 3251652Sgjb// 4251652Sgjb// The LLVM Compiler Infrastructure 5251652Sgjb// 6251652Sgjb// This file is dual licensed under the MIT and the University of Illinois Open 7251652Sgjb// Source Licenses. See LICENSE.TXT for details. 8251652Sgjb// 9251652Sgjb//===----------------------------------------------------------------------===// 10251652Sgjb 11251652Sgjb#ifndef _LIBCPP_EXT_HASH 12251652Sgjb#define _LIBCPP_EXT_HASH 13251652Sgjb 14251652Sgjb#pragma GCC system_header 15251652Sgjb 16251652Sgjb#include <string> 17251652Sgjb#include <cstring> 18251652Sgjb 19251652Sgjbnamespace __gnu_cxx { 20251652Sgjbusing namespace std; 21251652Sgjb 22251652Sgjbtemplate <typename _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash { }; 23251652Sgjb 24251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*> 25251652Sgjb : public unary_function<const char*, size_t> 26251652Sgjb{ 27251652Sgjb _LIBCPP_INLINE_VISIBILITY 28251652Sgjb size_t operator()(const char *__c) const _NOEXCEPT 29251652Sgjb { 30251652Sgjb return __do_string_hash(__c, __c + strlen(__c)); 31251652Sgjb } 32251652Sgjb}; 33251652Sgjb 34251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *> 35251652Sgjb : public unary_function<char*, size_t> 36251652Sgjb{ 37251652Sgjb _LIBCPP_INLINE_VISIBILITY 38251652Sgjb size_t operator()(char *__c) const _NOEXCEPT 39251652Sgjb { 40251652Sgjb return __do_string_hash<const char *>(__c, __c + strlen(__c)); 41251652Sgjb } 42251652Sgjb}; 43251652Sgjb 44251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<char> 45251652Sgjb : public unary_function<char, size_t> 46251652Sgjb{ 47251652Sgjb _LIBCPP_INLINE_VISIBILITY 48251652Sgjb size_t operator()(char __c) const _NOEXCEPT 49251652Sgjb { 50251652Sgjb return __c; 51251652Sgjb } 52251652Sgjb}; 53251652Sgjb 54251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<signed char> 55251652Sgjb : public unary_function<signed char, size_t> 56251652Sgjb{ 57251652Sgjb _LIBCPP_INLINE_VISIBILITY 58251652Sgjb size_t operator()(signed char __c) const _NOEXCEPT 59251652Sgjb { 60251652Sgjb return __c; 61251652Sgjb } 62251652Sgjb}; 63251652Sgjb 64251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char> 65251652Sgjb : public unary_function<unsigned char, size_t> 66251652Sgjb{ 67251652Sgjb _LIBCPP_INLINE_VISIBILITY 68251652Sgjb size_t operator()(unsigned char __c) const _NOEXCEPT 69251652Sgjb { 70251652Sgjb return __c; 71251652Sgjb } 72251652Sgjb}; 73251652Sgjb 74251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<short> 75251652Sgjb : public unary_function<short, size_t> 76251652Sgjb{ 77251652Sgjb _LIBCPP_INLINE_VISIBILITY 78251652Sgjb size_t operator()(short __c) const _NOEXCEPT 79251652Sgjb { 80251652Sgjb return __c; 81251652Sgjb } 82251652Sgjb}; 83251652Sgjb 84251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short> 85251652Sgjb : public unary_function<unsigned short, size_t> 86251652Sgjb{ 87251652Sgjb _LIBCPP_INLINE_VISIBILITY 88251652Sgjb size_t operator()(unsigned short __c) const _NOEXCEPT 89251652Sgjb { 90251652Sgjb return __c; 91251652Sgjb } 92251652Sgjb}; 93251652Sgjb 94251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<int> 95251652Sgjb : public unary_function<int, size_t> 96251652Sgjb{ 97251652Sgjb _LIBCPP_INLINE_VISIBILITY 98251652Sgjb size_t operator()(int __c) const _NOEXCEPT 99251652Sgjb { 100251652Sgjb return __c; 101251652Sgjb } 102251652Sgjb}; 103251652Sgjb 104251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int> 105251652Sgjb : public unary_function<unsigned int, size_t> 106251652Sgjb{ 107251652Sgjb _LIBCPP_INLINE_VISIBILITY 108251652Sgjb size_t operator()(unsigned int __c) const _NOEXCEPT 109251652Sgjb { 110251652Sgjb return __c; 111251652Sgjb } 112251652Sgjb}; 113251652Sgjb 114251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<long> 115251652Sgjb : public unary_function<long, size_t> 116251652Sgjb{ 117251652Sgjb _LIBCPP_INLINE_VISIBILITY 118251652Sgjb size_t operator()(long __c) const _NOEXCEPT 119251652Sgjb { 120251652Sgjb return __c; 121251652Sgjb } 122251652Sgjb}; 123251652Sgjb 124251652Sgjbtemplate <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long> 125251652Sgjb : public unary_function<unsigned long, size_t> 126251652Sgjb{ 127251652Sgjb _LIBCPP_INLINE_VISIBILITY 128251652Sgjb size_t operator()(unsigned long __c) const _NOEXCEPT 129251652Sgjb { 130251652Sgjb return __c; 131251652Sgjb } 132251652Sgjb}; 133251652Sgjb} 134251652Sgjb 135251652Sgjb#endif // _LIBCPP_EXT_HASH 136251652Sgjb