Beispiel #1
0
        public void ReturnsFalseIfKeyExistsInHashTable(string key)
        {
            MyHashTable <object> table = new MyHashTable <object>(50);

            table.Add(key, "value");
            bool actual = table.contains("False!!!!!");

            Assert.False(actual);
        }
 public MyHashTable <object> MyLeftJoint(MyHashTable <object> H1, MyHashTable <object> H2)
 {
     foreach (var bucket in H1.Table)
     {
         if (bucket != null)
         {
             foreach (var node in bucket)
             {
                 if (H2.contains(node.Key))
                 {
                     H1.Add(node.Key, H2.Get(node.Key));
                 }
                 Node newNode = new Node(null, null);
                 H1.Add(newNode.Key, newNode.Value);
             }
         }
     }
     return(H1);
 }
        /// <summary>
        /// Helper for tree two to check if tree one node value is in the hash table. If it is, add to result list.
        /// </summary>
        /// <param name="node">Node</param>
        private void CheckHash(MyNode node)
        {
            if (node == null)
            {
                return;
            }

            if (HT.contains(node.Value))
            {
                result.Add(node.Value);
            }

            if (node.Left != null)
            {
                CheckHash(node.Left);
            }

            if (node.Right != null)
            {
                CheckHash(node.Right);
            }
        }