public static void run() { #region Hash Table Test Console.WriteLine("\n----------------Hash Table Test-----------------"); Console.WriteLine("-------Hash Table Array Test:"); HashTableArray <string> tableArray = new HashTableArray <string>(3); tableArray.Add(312, "abcbca"); tableArray.Add(123, "qwer"); tableArray.Add(2, "qw"); tableArray.View(); Console.WriteLine("\nHash-table after removing by key 123:"); tableArray.Remove(123); tableArray.View(); Console.WriteLine("\n------Hash Table List Test:"); HashTableList <string> tableList = new HashTableList <string>(5); tableList.Add(1, "abc"); tableList.Add(6, "abc"); tableList.Add(11, "abc"); tableList.Add(16, "a"); tableList.Add(0, "bc"); tableList.View(); Console.WriteLine("\nHash-table after removing by key 11 & 0:"); tableList.Remove(11); tableList.Remove(0); tableList.View(); #endregion }
public void AddExistingKeyTest() { HashTableArray repository = new HashTableArray(2, new HashFuctionExample()); repository.Add("1", "item 1"); repository.Add("1", "item 1-2"); Assert.AreEqual("item 1-2", repository.Find("1")); }
public void FindTest() { HashTableArray repository = new HashTableArray(1, new HashFuctionExample()); repository.Add("1", "item 1"); Assert.IsNotNull(repository.Find("1")); }
public _003_HashTableArray() { HashTableArray <string, string> hashTableArray = new HashTableArray <string, string>(10); hashTableArray.Add("1", "2"); hashTableArray.Add("2", "3432"); hashTableArray.Add("3", "55555"); hashTableArray.Add("4", "8888"); hashTableArray.Update("4", "tttt"); foreach (var item in hashTableArray) { Console.WriteLine(item.Key); } }
public void HashTableFunctionTest() { HashTableArray repository = new HashTableArray(1, new HashFuctionExample()); repository.Add("1", "item 1"); repository.HashFunction = new HashFuctionExample(); Assert.IsNotNull(repository.Find("1")); Assert.AreEqual("item 1", repository.Find("1")); }
public void Add(TKey key, TValue value) { if (_count >= _maxItemsAtCurrentSize) { HashTableArray <TKey, TValue> largerArray = new HashTableArray <TKey, TValue>(_array.Capacity * 2); foreach (HashTableNodePair <TKey, TValue> node in _array.Items) { largerArray.Add(node.Key, node.Value); } } }