/// <summary> /// Represents a collection of key-value pairs that are ordered by a key hash. /// </summary> /// <param name="myHash"> Class instance, its interface </param> public HashTable(IMyHash myHash) { Hash = myHash; for (int i = 0; i != capacity; ++i) { hashTable[i] = new MyList(); } }
/// <summary> /// Change my hash /// </summary> /// <param name="myHash"> changed hash </param> public void ChangeHash(IMyHash myHash) { var list = new MyList(); for (int i = 0; i < capacity; i++) { while (hashTable[i].SizeOfList() != 0) { string value = hashTable[i].PopElement(); list.AddElement(value); } } Hash = myHash; while (list.SizeOfList() != 0) { string value = list.PopElement(); AddElementToHashTable(value); } }