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(); }
public void IsPrimeNumber_IfProvideValueGreaterThan100_ThrowException() { PrimeNumberFinder pf = new PrimeNumberFinder(); Action action = () => pf.IsPrimeNumber(101); Assert.Throws <Exception>(action); }
public void IsPrimeNumber_IfProvideValueIs6_ReturnFalse() { PrimeNumberFinder pf = new PrimeNumberFinder(); var actual = pf.IsPrimeNumber(6); Assert.False(actual); }
public void IsPrimeNumber_IfProvideValueIs11_ReturnTrue() { PrimeNumberFinder pf = new PrimeNumberFinder(); var actual = pf.IsPrimeNumber(11); Assert.True(actual); }
static void Main(string[] args) { PrimeNumberFinder snt = CheckPrimeNumber; OnPrimeNumber = snt; Console.WriteLine("Print Number from 1 to 10: "); for (int i = 1; i <= 10; i++) { if (OnPrimeNumber(i)) { Console.WriteLine(i + " is Prime Number!!!"); } else { Console.WriteLine(i); } } }