本文整理汇总了Python中tree.Tree.del_mutable方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.del_mutable方法的具体用法?Python Tree.del_mutable怎么用?Python Tree.del_mutable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Tree
的用法示例。
在下文中一共展示了Tree.del_mutable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_random_mutable_adds_and_deletes
# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import del_mutable [as 别名]
def test_random_mutable_adds_and_deletes(self):
t = Tree(10)
s = {10}
for _ in range(100):
r = random.randint(0, 100000000)
t.add_mutable(r)
s.add(r)
self.assertEqual(t.as_list(), sorted(s))
for i in range(99):
r = random.choice(list(s))
t.del_mutable(r)
s.remove(r)
self.assertEqual(t.as_list(), sorted(s), "problem in {}th delete".format(i))
示例2: test_del_immutable
# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import del_mutable [as 别名]
def test_del_immutable(self):
t = Tree(10).add_immutables(15, 5, 3, 7)
t = t.del_mutable(15)
self.assertEqual(t.as_list(),
[3, 5, 7, 10])
t = t.del_mutable(5)
self.assertEqual(t.as_list(),
[3, 7, 10])
t = t.del_mutable(10)
self.assertEqual(t.as_list(),
[3, 7])
t = Tree(10).add_mutable(15, 12, 11, 20, 25, 5, 3, 7,
1, 4, 6, 8)
self.assertEqual(t.as_list(),
[1, 3, 4, 5, 6, 7, 8, 10,
11, 12, 15, 20, 25])
t = t.del_mutable(25)
self.assertEqual(t.as_list(),
[1, 3, 4, 5, 6, 7, 8, 10,
11, 12, 15, 20])
t = t.del_mutable(11)
self.assertEqual(t.as_list(),
[1, 3, 4, 5, 6, 7, 8, 10,
12, 15, 20])
t = t.del_mutable(8)
self.assertEqual(t.as_list(),
[1, 3, 4, 5, 6, 7, 10,
12, 15, 20])
t = t.del_mutable(1)
self.assertEqual(t.as_list(),
[3, 4, 5, 6, 7, 10,
12, 15, 20])
t = t.del_mutable(7)
self.assertEqual(t.as_list(),
[3, 4, 5, 6, 10,
12, 15, 20])
t = t.del_mutable(3)
self.assertEqual(t.as_list(),
[4, 5, 6, 10,
12, 15, 20])
t = t.del_mutable(10)
self.assertEqual(t.as_list(),
[4, 5, 6,
12, 15, 20])