fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _04_MyHashTable
  7. {
  8. class CustomHashTableTest
  9. {
  10. static void Main(string[] args)
  11. {
  12. CustomHashTable<string, int> hashTable = new CustomHashTable<string, int>(4);
  13. hashTable.Add("a", 5);
  14. hashTable.Add("bb", 6);
  15. hashTable.Add("ccc", 7);
  16. hashTable.Add("d", 8);
  17. hashTable.Add("ee", 9);
  18. hashTable.Add("fff", 10);
  19. hashTable.Add("g", 11);
  20. hashTable.Add("hh", 12);
  21. hashTable.Add("iii", 13);
  22. hashTable.Add("j", 14);
  23. hashTable.Remove("j");
  24. string searchedKey = "bb";
  25. Console.WriteLine("Value of {0} is {1}.", searchedKey, hashTable.Find(searchedKey));
  26. foreach (KeyValuePair<string,int> pair in hashTable)
  27. {
  28. Console.WriteLine("Key -> {0}, Value -> {1}", pair.Key, pair.Value);
  29. }
  30. string indexKey = "g";
  31. Console.WriteLine("Indexator: element[{0}] = {1}", indexKey, hashTable[indexKey]);
  32. hashTable["g"] = 444;
  33. Console.WriteLine("Indexator: element[{0}](after change) = {1}", indexKey, hashTable[indexKey]);
  34. List<string> allKeys = hashTable.Keys;
  35. Console.Write("The keys are: ");
  36. foreach (string key in allKeys)
  37. {
  38. Console.Write("{0},", key);
  39. }
  40. Console.WriteLine(".");
  41. hashTable.Clear();
  42. }
  43. }
  44. }
  45.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty