public void ShouldGetFirstItemByKey() { var myHashTable = new MyHashTable(allocatedSizeOfTable); int hashCode = Hash.GenerateHash("a", allocatedSizeOfTable); myHashTable.Set("a", "a"); myHashTable.Set("a", "a2"); string result = myHashTable.GetFirst("a"); Assert.AreEqual(result, "a"); }
public void ShouldGetAllItemByKey() { var myHashTable = new MyHashTable(allocatedSizeOfTable); int hashCode = Hash.GenerateHash("a", allocatedSizeOfTable); myHashTable.Set("a", "a"); myHashTable.Set("a", "a2"); List <string> result = myHashTable.GetAll("a"); Assert.IsTrue(result.Count == 2); Assert.IsTrue(result[0] == "a"); Assert.IsTrue(result[1] == "a2"); }
public void Insert_Items_Testing_Colission() { var myHashTable = new MyHashTable <int>(10); string key = "myTest"; string key2 = "myTest2"; string key3 = "myTest7"; int value = 5; myHashTable.Set(key, 10); myHashTable.Set(key2, 2); myHashTable.Set(key3, value); int result = myHashTable.Get(key3); Assert.Equal(value, result); }
public void ShouldAddItemToHashTable() { var myHashTable = new MyHashTable(allocatedSizeOfTable); int hashCode = Hash.GenerateHash("a", allocatedSizeOfTable); myHashTable.Set("a", "a"); Assert.IsNotNull(myHashTable); Assert.IsTrue(myHashTable.LookpUp.Count == 1); Assert.IsNotNull(myHashTable.LookpUp.ContainsKey(hashCode)); }
public void Insert_An_Item_And_Get_It_Back() { var myHashTable = new MyHashTable <int>(10); string key = "myTest"; int value = 1000; myHashTable.Set(key, value); int result = myHashTable.Get(key); Assert.Equal(value, result); }
public void IntersectWith(MyHashedSet <T> other) { var resultTable = new MyHashTable <T, bool>(); foreach (var element in other) { if (this.Contains(element)) { resultTable.Set(element, true); } } this.elements = resultTable; }
public void SetAndGet_WhenCalled_SetsTheValueIntoTheCorrectIndex(string key, int value) { _hash.Set(key, value); Assert.That(_hash.Get(key), Is.EqualTo(value)); }