当前位置: 首页>>代码示例>>Python>>正文


Python Node.factory方法代码示例

本文整理汇总了Python中Node.Node.factory方法的典型用法代码示例。如果您正苦于以下问题:Python Node.factory方法的具体用法?Python Node.factory怎么用?Python Node.factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.factory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tree_insertion_equal_node

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_tree_insertion_equal_node(self):
     tree = Tree()
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(12))
     self.assertIsNotNone(tree.root_node)
     self.assertIsNotNone(tree.root_node.value)
     self.assertEqual(12, tree.root_node.value)
     self.assertIsNone(tree.root_node.left.value)
     self.assertIsNone(tree.root_node.right.value)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:11,代码来源:test_tree.py

示例2: test_node_assignment

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_node_assignment(self):
     node1 = Node.factory(25)
     node2 = Node.factory(None)
     self.assertIsNone(node2.value)
     self.assertIsNone(node2.left.value)
     self.assertIsNone(node2.right.value)
     node2.assign(node1)
     self.assertEqual(25, node2.value)
     self.assertIsNone(node2.left.value)
     self.assertIsNone(node2.right.value)
     node1.left = Node.factory(15)
     node1.right = Node.factory(35)
     node2.assign(node1)
     self.assertEqual(25, node2.value)
     self.assertEqual(15, node2.left.value)
     self.assertEqual(35, node2.right.value)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:18,代码来源:test_node.py

示例3: test_tree_multi_level_insertion

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_tree_multi_level_insertion(self):
     tree = Tree()
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(10))
     tree.insert(Node.factory(11))
     tree.insert(Node.factory(1))
     tree.insert(Node.factory(100))
     self.assertEqual(12, tree.root_node.value)
     self.assertEqual(100, tree.root_node.right.value)
     self.assertEqual(10, tree.root_node.left.value)
     self.assertEqual(11, tree.root_node.left.right.value)
     self.assertEqual(1, tree.root_node.left.left.value)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:15,代码来源:test_tree.py

示例4: test_deletion_leaf_node

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_deletion_leaf_node(self):
     tree = Tree()
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(10))
     tree.insert(Node.factory(11))
     tree.insert(Node.factory(1))
     tree.insert(Node.factory(100))
     tree.delete(Node.factory(1))
     self.assertTrue(tree.search(Node.factory(12)))
     self.assertTrue(tree.search(Node.factory(10)))
     self.assertTrue(tree.search(Node.factory(11)))
     self.assertFalse(tree.search(Node.factory(1)))
     self.assertTrue(tree.search(Node.factory(100)))
     self.assertEqual(12, tree.root_node.value)
     self.assertEqual(100, tree.root_node.right.value)
     self.assertEqual(10, tree.root_node.left.value)
     self.assertEqual(11, tree.root_node.left.right.value)
     self.assertEqual(None, tree.root_node.left.left.value)
     self.assertFalse(tree.root_node.left.left.value == 1)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:21,代码来源:test_tree.py

示例5: test_tree_search

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_tree_search(self):
     tree = Tree()
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(10))
     tree.insert(Node.factory(11))
     tree.insert(Node.factory(1))
     tree.insert(Node.factory(100))
     self.assertTrue(tree.search(Node.factory(12)))
     self.assertTrue(tree.search(Node.factory(10)))
     self.assertTrue(tree.search(Node.factory(11)))
     self.assertTrue(tree.search(Node.factory(1)))
     self.assertTrue(tree.search(Node.factory(100)))
     self.assertFalse(tree.search(Node.factory(None)))
     self.assertFalse(tree.search(Node.factory(123)))
     self.assertFalse(tree.search(Node.factory(0)))
     self.assertFalse(tree.search(Node.factory(-01)))
     self.assertFalse(tree.search(Node.factory(1001)))
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:20,代码来源:test_tree.py

示例6: test_deletion_node_with_two_children

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_deletion_node_with_two_children(self):
     tree = Tree()
     tree.insert(Node.factory(12))
     tree.insert(Node.factory(10))
     tree.insert(Node.factory(11))
     tree.insert(Node.factory(1))
     tree.insert(Node.factory(100))
     tree.insert(Node.factory(99))
     tree.delete(Node.factory(10))
     self.assertTrue(tree.search(Node.factory(12)))
     self.assertFalse(tree.search(Node.factory(10)))
     self.assertTrue(tree.search(Node.factory(11)))
     self.assertTrue(tree.search(Node.factory(1)))
     self.assertTrue(tree.search(Node.factory(100)))
     self.assertTrue(tree.search(Node.factory(99)))
     self.assertEqual(1, tree.root_node.left.value)
     self.assertEqual(11, tree.root_node.left.right.value)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:19,代码来源:test_tree.py

示例7: __init__

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def __init__(self, file_path):
     self.tree = Tree()
     with open(file_path) as f:
         for line in f:
             for word in line.split():
                 self.tree.insert(Node.factory(WordWrapper(word)))
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:8,代码来源:TreeImpl.py

示例8: test_node_factory

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_node_factory(self):
     node = Node.factory(12)
     self.assertEqual(12, node.value)
     self.assertIsNone(node.left.value)
     self.assertIsNone(node.right.value)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:7,代码来源:test_node.py

示例9: test_node_factory_none_case

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import factory [as 别名]
 def test_node_factory_none_case(self):
     self.assertIsNone(Node.factory(None).value)
     self.assertIsNone(Node.factory(None).left.value)
     self.assertIsNone(Node.factory(None).right.value)
开发者ID:mihirk,项目名称:binary_search_tree,代码行数:6,代码来源:test_node.py


注:本文中的Node.Node.factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。