hash-function

How to specialize std::hash<T> for user defined types?

你离开我真会死。 提交于 2019-12-14 03:44:48
问题 The Question What is a good specialization of std::hash for use in the third template parameter of std::unordered_map or std::unordered_set for a user defined type for which all member data types already have a good specialization of std::hash? For this question, I define "good" as simple to implement and understand, reasonably efficient, and unlikely to produce hash table collisions. The definition of good does not include any statements about security. The State of What is Google'able At

What are the downsides of using my own hashing algorithm instead of popular ones available?

僤鯓⒐⒋嵵緔 提交于 2019-12-13 07:54:05
问题 I am a noob in algorithms and not really so smart. But I have a question in my mind. There are a lot of hashing algorithms available and those might be 10 times more complex than what I wrote, but almost all of them are predictable these days. Recently, I read that writing my own hashing function is not a good idea. But why? I was wondering how a program/programmer can break my logic that (for example) creates a unique hash for each string in 5+ steps. Suppose someone successfully injected a

I need some direction on writing a Hash Function to sort ~160,000 strings

一曲冷凌霜 提交于 2019-12-12 12:08:51
问题 My instructor dumped this on us, and told us we just needed to google how to write a hash function. I am quite directionless on this. We wrote a basic Hash Table template for class, but I have a project due that requires ~160,000 strings to be sorted into a table with at least 500 buckets (I am wanting to do more for speed). I just have no idea where to look to get concise, easily digestible information on this. Any help would be greatly appreciated. 回答1: I suggest a universal hash function.

Hash code for expandable class (future proof)

陌路散爱 提交于 2019-12-11 20:51:47
问题 Since I don't have any great skills in math, I ask you if there exists any algorithm that I should use for a class which probably will change in the future. Consider following scenario: Class "Roles" has following fields: private boolean admin; private boolean printer; After some weeks I decide to add a role "guest": private boolean admin; private boolean printer; private boolean guest; After some weeks I decide to remove the role "printer"; private boolean admin; private boolean guest; Since

What's a good hash function for struct with 3 unsigned chars and an int, for unordered_map?

可紊 提交于 2019-12-11 18:09:56
问题 I just want to use a unordered_map with my struct as key, since I dont need any ordering..but I just cant find myself with all that hash stuff.. As a side relevant question..When ppl compare unordered and ordered map they never talk about the hash function, how can that be? Cant a bad hash function makes unordered map slower than map? (solely due the hash function) struct exemple{ unsigned char a,b,c; unsigned int n; bool operator == ( const exemple & other) const {..} }; namespace std {

Hash function for phone numbers

こ雲淡風輕ζ 提交于 2019-12-09 23:16:13
问题 I am building a hash table, where the key is a phone number (here are some of them): 6948060987 6960780800 6963208768 6944870406 6947279288 6953691771 6956094283 6947092062 6960086297 6947719197 6951516975 6957531584 6969211184 6963238579 6957054322 6952077216 6956907738 The number of entries will be 200, 2000, 20000 and 2000000 and the entries will be unique. About the size of the table, I am following this answer. I store the phone number as an array of char 's. I noticed that all the

Why Does a Bloom Filter Need Multiple Hash Functions?

≯℡__Kan透↙ 提交于 2019-12-08 07:01:00
问题 I don't really understand why a bloom filter requires multiple hash functions (say, SHA and MD5). Why not just make a bigger SHA hash, for example, and then break it up into multiple parts and treat them as separate hashes? Isn't that more efficient in terms of speed? 回答1: The idea is to use several different but simple hash functions. If you're going to use some cryptographic hash function like SHA or MD5 then you could just vary the input to it. Whether it's more efficient depends how

Constructing a hash table/hash function

你说的曾经没有我的故事 提交于 2019-12-07 06:54:05
问题 I would like to construct a hash table that looks up keys in sequences (strings) of bytes ranging from 1 to 15 bytes. I would like to store an integer value, so I imagine an array for hashing would suffice. I'm having difficulty conceptualizing how to construct a hash function such that given the key would give an index into the array. Any assistance would be much appreiated. The maximum number of entries in the hash is: 4081*15 + 4081*14 + ... 4081 = 4081((15*(16))/2) = 489720. So for

Hashing and encryption technique for a huge data set containing phone numbers

馋奶兔 提交于 2019-12-05 08:08:26
Description of problem: I'm in the process of working with a highly sensitive data-set that contains the people's phone number information as one of the columns. I need to apply (encryption/hash function on them) to convert them as some encoded values and do my analysis. It can be an one-way hash - i.e, after processing with the encrypted data we wont be converting them back to original phone numbers. Essentially, am looking for an anonymizer that takes phone numbers and converts them to some random value on which I can do my processing. Suggest the best way to do about this process.

Obtaining a k-wise independent hash function

百般思念 提交于 2019-12-05 01:23:16
问题 I need to use a hash function which belongs to a family of k-wise independent hash functions. Any pointers on any library or toolkit in C, C++ or python which can generate a set of k-wise independent hash functions from which I can pick a function. Background: I am trying to implement this algorithm here: http://researcher.watson.ibm.com/researcher/files/us-dpwoodru/knw10b.pdf for the Distinct Elements problem. I have looked at this thread: Generating k pairwise independent hash functions