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


Python LinkedList.delete方法代码示例

本文整理汇总了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")
开发者ID:ataicher,项目名称:learn_to_code,代码行数:9,代码来源:LinkedListTest.py

示例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")
开发者ID:ethanpierce,项目名称:DrZhao,代码行数:28,代码来源:unitTestLinkedList.py

示例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"  
开发者ID:ataicher,项目名称:learn_to_code,代码行数:11,代码来源:LinkedListTest.py

示例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
开发者ID:ataicher,项目名称:learn_to_code,代码行数:11,代码来源:LinkedListTest.py

示例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")
开发者ID:ataicher,项目名称:learn_to_code,代码行数:6,代码来源:LinkedListTest.py


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