Esempio n. 1
0
 def contains(self, key):
     """Checks if a certain key is in the tree
     Args:
         key (any) : a key which is compareable by <,>,==
     Returns:
         bool : True is the key exists, otherwise False
     """
     return bst.contains(self.tree, key)
Esempio n. 2
0
 def contains(self, key):
     """checks if a key exists within the tree, calls contains function in bst.py
     Args:
         key (*) : a key which is compareable by <,>,==
     Returns:
         bool : True is the key exists, otherwise False
     """
     return bst.contains(self.tree, key)
Esempio n. 3
0
 def contains(self, key):
     """ Checks to see if the tree contains the given key.
     Args:
         key (any) : a key which is compareable by <,>,==
     Returns:
         bool : True is the key exists, otherwise False
     """
     #call a function in the bst module
     return bst.contains(self.tree, key)
Esempio n. 4
0
    def contains(self, key):
        """Checks to see if the key exists in the BST tree map
        Calls contains function in bst.py

        Args:
            key (str) : the key (last name)
        Returns:
            boolean: Returns true if the key exists in the in TreeMap.
        """
        return contains(self.tree, key)
Esempio n. 5
0
 def test_bst_contains(self):
     t = None
     # Empty tree
     self.assertFalse(bst.contains(t, 5))
     t = bst.insert(t, 4, 'four')
     t = bst.insert(t, 2, 'two')
     t = bst.insert(t, 5, 'five')
     t = bst.insert(t, 1, 'one')
     t = bst.insert(t, 0, 'zero')
     t = bst.insert(t, 3, 'three')
     t = bst.insert(t, 9, 'nine')
     t = bst.insert(t, 6, 'six')
     t = bst.insert(t, 7, 'seven')
     t = bst.insert(t, 8, 'eight')
     # Not Contained
     self.assertFalse(bst.contains(t, 44))
     # Contained
     self.assertTrue(bst.contains(t, 2))
     self.assertTrue(bst.contains(t, 8))