/* Функция для удлинения хеш-таблицы */ public void PrintTable() { for (long i = 0; i < TABLE_SIZE; i++) { Console.Write($"\nЯчейка {i}: "); LinkedHash entry = table[i]; while (entry != null) { Console.Write(entry.Value + " "); entry = entry.Next; } } }
public void PrintValueSilent(long key) { if (table[key] == null) // не найдено { return; } // читать пока можно LinkedHash entry = table[key]; while (entry != null) { entry = entry.Next; } }
/* Функция для получения значения ключа */ public void PrintValue(long key) { if (table[key] == null) // не найдено { Console.WriteLine("Пусто"); return; } // читать пока можно LinkedHash entry = table[key]; while (entry != null) { Console.Write(entry.Value + " "); entry = entry.Next; } }
// Добавить значение public void Add(long value) { long hash = Hash(value) % TABLE_SIZE; long key = hash; if (table[hash] == null) { table[hash] = new LinkedHash(key, value); } else { LinkedHash entry = table[hash]; while (entry.Next != null) { entry = entry.Next; } entry.Next = new LinkedHash(key, value); } }