static void Main(string[] args) { string filePath = DATA_FILE_PATH; string searchFilePath = DATA_FILE_PATH; TABLE_SIZE = SetTableSize(filePath); LARGEST_PRIME = PrimeNumberFinder.FindLargestPrime(TABLE_SIZE); if (!(TABLE_SIZE > default(int))) { return; } List <int> insertFileData = FillListWithData(filePath); List <int> searchFileData = FillListWithData(searchFilePath); HashtableDto[] hashtableLinear = new HashtableDto[TABLE_SIZE]; FillHashtableWithNulls(TABLE_SIZE, hashtableLinear); HashtableDto[] hashtableDouble = new HashtableDto[TABLE_SIZE]; Array.Copy(hashtableLinear, hashtableDouble, TABLE_SIZE); InsertValuesLinearProbing(insertFileData, hashtableLinear, FILL_PERCENTAGE); InsertValuesDoubleHashing(insertFileData, hashtableDouble, FILL_PERCENTAGE); foreach (var value in searchFileData) { LinearProbingController.Search(hashtableLinear, new HashtableDto(value, value)); DoubleHashingController.Search(hashtableDouble, new HashtableDto(value, value)); } View.PrintAllResults(); }
private static void InsertValuesLinearProbing(List <int> dataValues, HashtableDto[] hashtable, double fillPercentage) { int filledValues = 0; foreach (var value in dataValues) { LinearProbingController.Insert(hashtable, new HashtableDto(value, value)); filledValues++; if (filledValues / (double)TABLE_SIZE > FILL_PERCENTAGE) { return; } } }