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


Python SinglyLinkedList.deleteHead方法代码示例

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


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

示例1: test_delete_head_with_one_element_list

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_delete_head_with_one_element_list(self):
        singlyLinkedListObject = SinglyLinkedList()
        singlyLinkedListObject.populate([1])

        singlyLinkedListObject.deleteHead()
        outputList = singlyLinkedListObject.returnLinkedListAsList()
        self.assertTrue(len(outputList) == 0, "After deleting the only element in the list, Output List must be empty")
开发者ID:prab-pip,项目名称:IntPrep,代码行数:9,代码来源:SinglyLinkedListTests.py

示例2: test_length_of_list_after_list_change_operations

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_length_of_list_after_list_change_operations(self):
        singlyLinkedListObject = SinglyLinkedList()

        inputList = range(10)
        singlyLinkedListObject.populate(inputList)

        expectedLength = len(inputList)

        actualLength = len(singlyLinkedListObject)

        self.assertTrue(expectedLength == actualLength, "Expected length: %s, Actual Length: %s" %(expectedLength, actualLength))

        singlyLinkedListObject.deleteHead()

        expectedLength -= 1

        actualLength = len(singlyLinkedListObject)

        self.assertTrue(expectedLength == actualLength, "Expected length: %s, Actual Length: %s" %(expectedLength, actualLength))

        singlyLinkedListObject.insertAtHead(200)
        expectedLength += 1

        actualLength = len(singlyLinkedListObject)

        self.assertTrue(expectedLength == actualLength, "Expected length: %s, Actual Length: %s" %(expectedLength, actualLength))


        singlyLinkedListObject.insertAtHead(200)
        expectedLength += 1

        actualLength = len(singlyLinkedListObject)

        self.assertTrue(expectedLength == actualLength, "Expected length: %s, Actual Length: %s" %(expectedLength, actualLength))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:36,代码来源:SinglyLinkedListTests.py

示例3: test_delete_head_of_list_with_one_item

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_delete_head_of_list_with_one_item(self):
        singlyLinkedListObject = SinglyLinkedList()

        inputList = [1]
        singlyLinkedListObject.populate(inputList)

        singlyLinkedListObject.deleteHead()
        self.assertTrue(singlyLinkedListObject.isHeadNone(), "Now that the only element in the list is deleted, Head of empty list must be None")

        singlyLinkedListObject.deleteHead()
        self.assertTrue(singlyLinkedListObject.isHeadNone(), "Now that the only element in the list is deleted, Head of empty list must be None")
开发者ID:prab-pip,项目名称:IntPrep,代码行数:13,代码来源:SinglyLinkedListTests.py

示例4: test_delete_head_from_a_list_with_more_than_two_elements

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_delete_head_from_a_list_with_more_than_two_elements(self):
        singlyLinkedListObject = SinglyLinkedList()
        inputList = range(20)
        singlyLinkedListObject.populate(inputList)

        # Deleting the first element from the inputList. this will help in assertion
        inputList.pop(0)

        singlyLinkedListObject.deleteHead()
        outputList = singlyLinkedListObject.returnLinkedListAsList()
        self.assertTrue(inputList == outputList, "Expecting one lesser value in the Output List but got different. Expected: %s, Got: %s" %(inputList, outputList))

        self.assertTrue(singlyLinkedListObject.head != singlyLinkedListObject.tail, "Tail and Head must NOT be the same after only 1 element remains in the list")
开发者ID:prab-pip,项目名称:IntPrep,代码行数:15,代码来源:SinglyLinkedListTests.py

示例5: test_changing_list_length_during_delete_head_operation

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_changing_list_length_during_delete_head_operation(self):
        singlyLinkedListObject = SinglyLinkedList()

        inputList = range(10)
        singlyLinkedListObject.populate(inputList)

        expectedLength = len(inputList)
        actualLength = len(singlyLinkedListObject)
        self.assertTrue(expectedLength == actualLength, "Expected length: %s, Actual Length: %s" %(expectedLength, actualLength))

        for data in inputList:
            singlyLinkedListObject.deleteHead()

            actualLength = len(singlyLinkedListObject)
            expectedLength -= 1  # Because a new element has been added to the list.
            self.assertTrue(expectedLength == actualLength, "Expected length: %s, Actual Length: %s" %(expectedLength, actualLength))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:18,代码来源:SinglyLinkedListTests.py

示例6: test_delete_head_of_empty_list_more_than_once

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_delete_head_of_empty_list_more_than_once(self):
        singlyLinkedListObject = SinglyLinkedList()

        singlyLinkedListObject.deleteHead()
        self.assertTrue(singlyLinkedListObject.isHeadNone(), "Head of empty list must be None")

        singlyLinkedListObject.deleteHead()
        self.assertTrue(singlyLinkedListObject.isHeadNone(), "Head of empty list must be None")

        singlyLinkedListObject.deleteHead()
        self.assertTrue(singlyLinkedListObject.isHeadNone(), "Head of empty list must be None")
开发者ID:prab-pip,项目名称:IntPrep,代码行数:13,代码来源:SinglyLinkedListTests.py

示例7: test_delete_head_of_list_with_more_than_one_item

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
    def test_delete_head_of_list_with_more_than_one_item(self):
        singlyLinkedListObject = SinglyLinkedList()

        inputList = [1, 2, 3]
        singlyLinkedListObject.populate(inputList)

        singlyLinkedListObject.deleteHead()
        self.assertFalse(singlyLinkedListObject.isHeadNone(), "Head of non-empty list must NOT be None")
        self.assertFalse(singlyLinkedListObject.head == 2, "Expected hea data: %s, Actual head data: %s" %(2, singlyLinkedListObject.head))

        singlyLinkedListObject.deleteHead()
        self.assertFalse(singlyLinkedListObject.isHeadNone(), "Head of non-empty list must NOT be None")

        self.assertFalse(singlyLinkedListObject.head == 3, "Expected hea data: %s, Actual head data: %s" %(3, singlyLinkedListObject.head))


        singlyLinkedListObject.deleteHead()
        self.assertTrue(singlyLinkedListObject.isHeadNone(), "Head of Empty list must be None")
开发者ID:prab-pip,项目名称:IntPrep,代码行数:20,代码来源:SinglyLinkedListTests.py

示例8: test_delete_head_on_empty_list

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import deleteHead [as 别名]
 def test_delete_head_on_empty_list(self):
     singlyLinkedListObject = SinglyLinkedList()
     self.assertTrue(singlyLinkedListObject.deleteHead(), "With no elements in the list, it should return True")
     outputList = singlyLinkedListObject.returnLinkedListAsList()
     self.assertTrue(len(outputList) == 0, "Output list from an Empty Linked List must be empty")
开发者ID:prab-pip,项目名称:IntPrep,代码行数:7,代码来源:SinglyLinkedListTests.py


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