本文整理汇总了Python中linkedlist.LinkedList.delete方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.delete方法的具体用法?Python LinkedList.delete怎么用?Python LinkedList.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linkedlist.LinkedList
的用法示例。
在下文中一共展示了LinkedList.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_value_not_in_list
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import delete [as 别名]
def test_delete_value_not_in_list():
l_list = LinkedList()
l_list.insert("Jacob")
l_list.insert("Pallymay")
l_list.insert("Rasmus")
with pytest.raises(ValueError):
l_list.delete("Sunny")
示例2: main
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import delete [as 别名]
def main():
#Create list of names
listOfNames = { "Tom", "Harry","Susan","Ethan","Willy","Shaina"}
#Create linkedlist object
testinglist = LinkedList()
#Test insertion method
for name in listOfNames:
testinglist.insert(name)
#Test size of list
print testinglist.size()
#Test print list
testinglist.printList()
#Test Deletion of head node
testinglist.delete("Tom")
#Test Deletion method:
testinglist.delete("Susan")
testinglist.printList()
#Test search list
testinglist.search("Willy")
示例3: test_delete_next_reassignment
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import delete [as 别名]
def test_delete_next_reassignment():
l_list = LinkedList()
l_list.insert("Jacob")
l_list.insert("Cid")
l_list.insert("Pallymay")
l_list.insert("Rasmus")
l_list.delete("Pallymay")
l_list.delete("Cid")
assert l_list.head.next_node.get_data() == "Jacob"
示例4: test_delete
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import delete [as 别名]
def test_delete():
l_list = LinkedList()
l_list.insert("Jacob")
l_list.insert("Pallymay")
l_list.insert("Rasmus")
l_list.delete("Rasmus")
assert l_list.head.get_data() == "Pallymay"
l_list.delete("Jacob")
assert l_list.head.get_next() is None
示例5: test_delete_empty_list
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import delete [as 别名]
def test_delete_empty_list():
l_list = LinkedList()
with pytest.raises(ValueError):
l_list.delete("Sunny")