public void insert(int key, string data) { if (!checkOpenSpace())//if no open spaces available { Console.WriteLine("table is at full capacity!"); return; } int hash = (key % maxSize); while (table[hash] != null && table[hash].getkey() != key) { hash = (hash + 1) % maxSize; } table[hash] = new hashentry(key, data); }
public void doubleHashInsert(int key, string data) { // double probing method if (!checkOpenSpace()) { Console.WriteLine("table is at full capacity!"); return; } int hashVal = hash1(key); int stepSize = hash2(key); while (table[hashVal] != null && table[hashVal].getKey() != key) { hashVal = (hashVal + stepSize * hash2(key)) % maxSize; } table[hashVal] = new hashentry(key, data); return; }
public void quadraticHashInsert(int key, string data) { // quadratic probing method if (!checkOpenSpace()) { Console.WriteLine("table is at full capacity!"); return; } int j = 0; int hash = key % maxSize; while (table[hash] != null && table[hash].getKey() != key) { j++; hash = (hash + j * j) % maxSize; } if (table[hash] == null) { table[hash] = new hashentry(key, data); return; } }