// STRING private static void HashStorageWithStrings() { var hashStorage = new HashStorage <string>(); var data = GenerateStringData(); hashStorage.Add("!!!"); hashStorage.Add("~~~~~"); hashStorage.Add("cda"); foreach (var i in data) { hashStorage.Add(i); } Console.WriteLine("---== STRING ==---"); Console.WriteLine(hashStorage.ToString()); }
// DOUBLE private static void HashStorageWithDoubles(int size) { var hashStorage = new HashStorage <double>(); var data = GenerateDoubleData(size); foreach (var i in data) { hashStorage.Add(i); } Console.WriteLine("---== DOUBLE ==---"); Console.WriteLine(hashStorage.ToString()); const double element = 2.0; try { hashStorage.Add(element); } catch (Exception exception) { Console.WriteLine($"Trying add {element}: {exception.Message}"); } }
// INT private static void HashStorageWithInts(int size) { var hashStorage = new HashStorage <int>(); var data = GenerateIntData(size); foreach (var i in data) { hashStorage.Add(i); } Console.WriteLine("---== INT ==---"); Console.Write(hashStorage.ToString()); Console.WriteLine("Removing..."); RemoveSomeIntData(hashStorage, 20); Console.Write(hashStorage.ToString()); const int element = 21; Console.WriteLine($"Is '21' in collection?: {hashStorage.Contains(element)}\n"); }