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


Python LinkedList.insert_after方法代码示例

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


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

示例1: test_insert_after_updates_length

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_insert_after_updates_length(self):
     ll = LinkedList()
     item1 = ll.add_to_front(5151, 91951)
     assert ll.length == 1
     ll.insert_after(item1, 123, 234)
     assert ll.length == 2
     ll.insert_after(item1, 987234, "kjnsdfjn")
     assert ll.length == 3
开发者ID:teroqim,项目名称:linkedlist,代码行数:10,代码来源:test_linkedlist.py

示例2: test_insert_after

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_insert_after(self):
     llist = LinkedList()
     for i in xrange(10):
         llist.push_back(i)
     for item in llist:
         if item.value % 2 == 0:
             llist.insert_after(item, item.value - 1)
     self.assertEqual([0,-1,1,2,1,3,4,3,5,6,5,7,8,7,9], [node.value for node in llist])
开发者ID:sthe0,项目名称:task3,代码行数:10,代码来源:test.py

示例3: test_insert_after

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_insert_after(self):
     ll = LinkedList()
     item1 = ll.add_to_front(5151, 91951)
     assert item1.next == None
     item2 = ll.insert_after(item1, 123, 234)
     assert item1.next == item2
     item3 = ll.insert_after(item1, 987234, "kjnsdfjn")
     assert item1.next == item3
     assert item3.next == item2
     assert item3.prev == item1
     assert item2.prev == item3
开发者ID:teroqim,项目名称:linkedlist,代码行数:13,代码来源:test_linkedlist.py

示例4: test_insert_after_return_new_item

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_insert_after_return_new_item(self):
     ll = LinkedList()
     item1 = ll.add_to_front(5151, 91951)
     key = 123
     value = [1,2,3]
     item2 = ll.insert_after(item1, key, value)
     assert item2.key == key
     assert item2.value == value
开发者ID:teroqim,项目名称:linkedlist,代码行数:10,代码来源:test_linkedlist.py

示例5: test_cannot_insert_after_item_from_other_list

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_cannot_insert_after_item_from_other_list(self):
     ll = LinkedList()
     ll2 = LinkedList()
     item_from_ll = ll.add_to_front(123, 123)
     with pytest.raises(Exception):
         ll2.insert_after(item_from_ll, 123, 1414)
开发者ID:teroqim,项目名称:linkedlist,代码行数:8,代码来源:test_linkedlist.py

示例6: test_cannot_insert_after_None

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_cannot_insert_after_None(self):
     ll = LinkedList()
     with pytest.raises(Exception):
         ll.insert_after(None, 123, 1414)
开发者ID:teroqim,项目名称:linkedlist,代码行数:6,代码来源:test_linkedlist.py

示例7: test_insert_after_updates_back

# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import insert_after [as 别名]
 def test_insert_after_updates_back(self):
     ll = LinkedList()
     item1 = ll.add_to_front(5151, 91951)
     assert ll.back == item1
     item2 = ll.insert_after(item1, 123, 234)
     assert ll.back == item2
开发者ID:teroqim,项目名称:linkedlist,代码行数:8,代码来源:test_linkedlist.py


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