Ejemplo n.º 1
0
 def test_treemap2(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     self.assertEqual(t.tree_height(), 3)
Ejemplo n.º 2
0
 def test_treemap4(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     self.assertEqual(t.find_max(), (7,'seven'))
Ejemplo n.º 3
0
 def test_treemap9(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     t.delete(6)
     self.assertEqual(t.tree_height(), 2)
     self.assertEqual(t.find_max(), (7,'seven'))
     self.assertEqual(t.find_min(), (1,'one'))
     t.delete(7)
     self.assertEqual(t.tree_height(), 2)
     self.assertEqual(t.find_max(), (5,'five'))
     t.delete(4)
     self.assertEqual(t.tree_height(), 2)
     self.assertEqual(t.find_max(), (5,'five'))
     self.assertEqual(t.tree.key, 5)
Ejemplo n.º 4
0
 def test_treemap8(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     self.assertEqual(t.range_search(3, 6), ['three', 'four', 'five'])
Ejemplo n.º 5
0
 def test_treemap7(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     self.assertEqual(t.get(5), 'five')
     self.assertEqual(t.get(4), 'four')
Ejemplo n.º 6
0
 def test_treemap6(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     self.assertEqual(t.preorder_list(), [4, 2, 1, 3, 7, 5, 6])
Ejemplo n.º 7
0
 def test_treemap5(self):
     t = TreeMap()
     t.put(4, 'four')
     t.put(2, 'two')
     t.put(3, 'three')
     t.put(1, 'one')
     t.put(7, 'seven')
     t.put(5, 'five')
     t.put(6, 'six')
     self.assertEqual(t.inorder_list(), [1, 2, 3, 4, 5, 6, 7])