double-hashing

how to search using double hash in c

寵の児 提交于 2019-12-25 02:57:49
问题 I have a server to receive request from multiple client. I have done this with threads. I want to insert some user name and password to hash table. For that I am using double hash method. It was inserted successfully. But I want to know when user enter a user name, I need to search on hash table whether this username already present. But I can't do it now. I know the concept like using hashing. Get the index using hashfunction1 through username and use double hash like this. But how can I

Hashing a string for use in hash table (Double Hashing)

瘦欲@ 提交于 2019-12-25 02:43:32
问题 I am trying to use Double Hashing to hash a String key into a hash table. I did something like: protected int getIndex(String key) { int itr = 0, size = this.values.length, index1, index2, index = 0; do { // do double hashing to get index for curr [itr] (iteration) index1 = Math.abs(key.hashCode()) % size; index2 = size - ((key + key + "#!@").hashCode() % size); # trying very hard to eliminate clash, but still fails ... TA and AT gets index 2 when size = 5 index = (index1 + (itr * index2)) %

Double Hashing java

南楼画角 提交于 2019-12-11 19:36:30
问题 public class HashTable <K, V> implements Table<K, V>{ int idx; PairHolder table[]; public HashTable(int size){ table=new PairHolder[size]; } public void put(K key, V value) { int hVal = key.hashCode(); int hashVal = hashFunc1(hVal); int stepSize = hashFunc2(hVal); while(table[index]!=null&&table[index].getFirst() != null){ index += temp; index %=table.length; } table[index].value=value; } public int hashFunc1(int key){ int abs = Math.abs(key%table.length); return abs; } public int hashFunc2