public static void Main(string[] args) { HashTableForString hashtable = new HashTableForString( new SimpleDivisionStringHF(500), new OnMultiplicationBasedRHF(3, 500) ); // Adding hashtable.Add("str1"); hashtable.Add("str2"); hashtable.Add("str3"); // Removing hashtable.Remove("str3"); // Removing with rehash // GetHash // IsExist // LevelOfRehash }
/// <summary> /// Метод для отрисовки Таблицы Идетификаторов. /// </summary> /// <param name="ht"></param> public static void DrawIdentTableToConsole(HashTableForString ht) { string[] values = ht.GetOnlyNotNullValues(); for (int i = 0; i < values.Length; i++) { Console.WriteLine("[ {0} ] = {1}", i, values[i]); } }
public void Start(FileInfo file) { // Считывание всего файла string allFile = this.ReadToEnd(file); // Создание хэш-таблицы int fileLen = Int32.MaxValue; if (file.Length < Int32.MaxValue) { fileLen = (int)file.Length; } hashTable = new HashTableForString( new SimpleAdaptStringHF(fileLen), new OnRandomBasedRHF(fileLen) ); // Лексический анализ LexemScanner lexScan = new LexemScanner(allFile); lexScan.NotifyAboutIdentificator += this.OnAddIdentificator; List <LexemDataCell> lexTable = lexScan.DoAnalysis(); // Синтаксический анализ SyntaxScanner synAnal = new SyntaxScanner(lexTable); List <OutputTreeCell> tree = synAnal.DoAnalysis(); // Отрисовка получившегося дерева в консоль if (NeedToShowOutputtree) { this.WriteLineColor("OutPut tree:", ConsoleColor.DarkGreen, false); Drawer.DrawOutputTreeToConsole(tree); Console.WriteLine(); } // Отрисовка таблицы лексем if (NeedToShowLexemTable) { this.WriteLineColor("Lexem table:", ConsoleColor.DarkRed, false); Drawer.DrawLexTableToConsole(lexTable); Console.WriteLine(); } // Отрисовка отрисовка таблицы идентификаторов if (NeedToShowIdentificatorTable) { this.WriteLineColor("Identificator table:", ConsoleColor.DarkYellow, false); Drawer.DrawIdentTableToConsole(hashTable); Console.WriteLine(); } }