In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
#pragma once#include #include "BitMap.h"struct HashFunc1{ size_t BKDRHash(const char *str) { register size_t hash = 0; while (size_t ch = (size_t)*str++) { hash = hash * 131 + ch; // 也可以乘以31、131 return hash; } } size_t operator()(const string& s) { return BKDRHash(s.c_str()); }};struct HashFunc2{ size_t SDBMHash(const char *str) { register size_t hash = 0; while (size_t ch = (size_t)*str++) { hash = 65599 * hash + ch; } return hash; } size_t operator()(const string& s) { return SDBMHash(s.c_str()); }};struct HashFunc3{ size_t RSHash(const char *str) { register size_t hash = 0; size_t magic = 63689; while (size_t ch = (size_t)*str++) { hash = hash * magic + ch; magic *= 378551; } return hash; } size_t operator()(const string& s) { return RSHash(s.c_str()); }};struct HashFunc4{ size_t APHash(const char *str) { register size_t hash = 0; size_t ch; for (long i = 0; ch = (size_t)*str++; i++) { if ((i & 1) == 0) { hash ^= ((hash > 3)); } else { hash ^= (~((hash > 5))); } } return hash; } size_t operator()(const string& s) { return APHash(s.c_str()); }};struct HashFunc5{ size_t JSHash(const char *str) { if(!*str) return 0; register size_t hash = 1315423911; while (size_t ch = (size_t)*str++) { hash ^= ((hash > 2)); } return hash; } size_t operator()(const string& s) { return JSHash(s.c_str()); }};templateclass BloomFilter{public: BloomFilter(size_t size) :_bitMap(size) ,_capacity(size) {} void Set(const K& key) { size_t index1 = __HashFunc1()(key); size_t index2 = __HashFunc2()(key); size_t index3 = __HashFunc3()(key); size_t index4 = __HashFunc4()(key); size_t index5 = __HashFunc5()(key); cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.