コード例 #1
0
ファイル: Program.cs プロジェクト: P3piK/Aads
        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();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: P3piK/Aads
        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;
                }
            }
        }