public static bool Insert(HashtableDto[] hashtable, HashtableDto data) { for (int i = 0; i < Program.TABLE_SIZE; i++) { int key = HashingJoint(data, i); insertCount++; if (hashtable[key] == null) { hashtable[key] = data; return(true); } } return(false); }
public static bool Insert(HashtableDto[] hashtable, HashtableDto data) { for (int i = 0; i < hashtable.Length; i++) { int key = HashingFunction(data, i); insertCount++; if (hashtable[key] == null) { hashtable[key] = data; return(true); } } return(false); }
public static bool Search(HashtableDto[] hashtable, HashtableDto data) { for (int i = 0; i < Program.TABLE_SIZE; i++) { int key = HashingJoint(data, i); searchCount++; if (hashtable[key] == data) { return(true); } else if (hashtable[key] == null) { return(false); } searchMissCount++; } return(false); }
public static bool Search(HashtableDto[] hashtable, HashtableDto data) { for (int i = 0; i < hashtable.Length; i++) { int key = HashingFunction(data, i); searchCount++; if (hashtable[key] == data) { return(true); } else if (hashtable[key] == null) { return(false); } searchMissCount++; } return(false); }
private static int Hashing2(HashtableDto data) { return(Program.LARGEST_PRIME - (data.Key % Program.LARGEST_PRIME)); }
private static int Hashing1(HashtableDto data) { return(data.Key % Program.TABLE_SIZE); }
private static int HashingJoint(HashtableDto data, int i) { return((Hashing1(data) + i * Hashing2(data)) % Program.TABLE_SIZE); }
private static int HashingFunction(HashtableDto data, int i) { return((data.Key + i) % Program.TABLE_SIZE); }