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


Python SinglyLinkedList.returnLinkedListAsList方法代码示例

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


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

示例1: test_delete_head_with_one_element_list

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [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_append_when_list_is_empty

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_append_when_list_is_empty(self):
        singlyLinkedListObject = SinglyLinkedList()
        inputVal = 10
        singlyLinkedListObject.appendToListUsingTail(inputVal)
        outputList = singlyLinkedListObject.returnLinkedListAsList()
        outputVal = outputList[0]

        self.assertTrue(inputVal == outputVal, "Expected a tail value of: %s, Got: %s" %(inputVal, outputVal))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:10,代码来源:SinglyLinkedListTests.py

示例3: test_populate

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

        inputList = range(20)
        singlyLinkedListObject.populate(inputList)
        outputList = singlyLinkedListObject.returnLinkedListAsList()

        self.assertTrue(inputList == outputList, "Input List: %s and Output List: %s don't match" %(inputList, outputList))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:10,代码来源:SinglyLinkedListTests.py

示例4: test_reverse_an_empty_list

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_reverse_an_empty_list(self):
        originalList = SinglyLinkedList() # Because it's an empty list, no need to populate it

        s = Solution()
        s.reverseOriginalList_Iterative(originalList)

        inputList = []
        expectedList = inputList
        returnedList = originalList.returnLinkedListAsList()
        self.assertTrue(expectedList == returnedList, "Expected: %s, Got: %s" %(expectedList, returnedList))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:12,代码来源:Test_ReverseASinglyLinkedList.py

示例5: test_reverse_a_list_with_two_elements

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_reverse_a_list_with_two_elements(self):
        originalList = SinglyLinkedList()
        inputList = [10, 20]
        originalList.populate(inputList)

        s = Solution()

        s.reverseOriginalLinkedList_Recursive(originalList)

        expectedList = inputList[::-1]
        returnedList = originalList.returnLinkedListAsList()
        self.assertTrue(expectedList == returnedList, "Expected: %s, Got: %s" %(expectedList, returnedList))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:14,代码来源:Test_ReverseASinglyLinkedList.py

示例6: test_add_without_carry_basic_case_both_lists_empty

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_add_without_carry_basic_case_both_lists_empty(self):
        firstList = SinglyLinkedList()
        secondList = SinglyLinkedList()
        outputList = SinglyLinkedList()

        s = Solution(firstList, secondList, outputList)
        s.addTwoNonReversedIntegersAsLinkedListsAndCreateNewList()

        outputValue = outputList.returnLinkedListAsList()
        expectedValue = []

        self.assertTrue(outputValue == expectedValue, "Expected: %s, Got: %s" %(expectedValue, outputValue))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:14,代码来源:Test_TwoDotFive_AddTwoNonReversedIntegersAsLinkedLists.py

示例7: test_reverse_a_list_with_many_elements

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_reverse_a_list_with_many_elements(self):
        givenList = SinglyLinkedList()
        inputList = range(10,101,10)
        givenList.populate(inputList)

        s = Solution()

        outputLinkedList = SinglyLinkedList()
        s.returnReversedListUsingRecursion(givenList.head, outputLinkedList)
        
        expectedList = inputList[::-1]
        returnedList = outputLinkedList.returnLinkedListAsList()
        self.assertTrue(expectedList == returnedList, "Expected: %s, Got: %s" %(expectedList, returnedList))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:15,代码来源:Test_ReverseASinglyLinkedList.py

示例8: test_append_when_list_has_at_least_one_element

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

        inputVal = 10
        singlyLinkedListObject.appendToListUsingTail(inputVal)

        self.assertTrue(singlyLinkedListObject.tail.data == inputVal, "Expected Tail data: %s, Got: %s" %(inputVal, singlyLinkedListObject.tail.data))

        outputList = singlyLinkedListObject.returnLinkedListAsList()
        outputVal = outputList[-1]
        self.assertTrue(inputVal == outputVal, "Expected tail value: %s, Got: %s" %(inputVal, outputVal))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:15,代码来源:SinglyLinkedListTests.py

示例9: 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 returnLinkedListAsList [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

示例10: test_add_with_carry_forever_carry_till_last

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_add_with_carry_forever_carry_till_last(self):
        firstList = SinglyLinkedList()
        secondList = SinglyLinkedList()
        outputList = SinglyLinkedList()

        firstList.populate([9,9,9,9,9,9,9])
        secondList.populate([1])

        s = Solution(firstList, secondList, outputList)
        s.addTwoNonReversedIntegersAsLinkedListsAndCreateNewList()

        outputValue = outputList.returnLinkedListAsList()
        expectedValue = [1, 0, 0, 0, 0, 0, 0, 0]
        self.assertTrue(outputValue == expectedValue, "Expected: %s, Got: %s" %(expectedValue, outputValue))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:16,代码来源:Test_TwoDotFive_AddTwoNonReversedIntegersAsLinkedLists.py

示例11: test_add_without_carry_basic_case_first_list_empty_second_list_has_one_element

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_add_without_carry_basic_case_first_list_empty_second_list_has_one_element(self):
        firstList = SinglyLinkedList()
        secondList = SinglyLinkedList()
        outputList = SinglyLinkedList()

        inputValue = [1]
        secondList.populate(inputValue)
        s = Solution(firstList, secondList, outputList)

        s.addTwoNonReversedIntegersAsLinkedListsAndCreateNewList()
        outputValue = outputList.returnLinkedListAsList()
        expectedValue = inputValue

        self.assertTrue(outputValue == expectedValue, "Expected: %s, Got: %s" %(expectedValue, outputValue))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:16,代码来源:Test_TwoDotFive_AddTwoNonReversedIntegersAsLinkedLists.py

示例12: test_add_without_left_over_carry_both_lists_have_unequal_items

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_add_without_left_over_carry_both_lists_have_unequal_items(self):
        firstList = SinglyLinkedList()
        secondList = SinglyLinkedList()
        outputList = SinglyLinkedList()

        firstList.populate([7,1,6,9])
        secondList.populate([5,9,2])

        s = Solution(firstList, secondList, outputList)
        s.addTwoNonReversedIntegersAsLinkedListsAndCreateNewList()

        outputValue = outputList.returnLinkedListAsList()
        expectedValue = [7,7,6,1]
        self.assertTrue(outputValue == expectedValue, "Expected: %s, Got: %s" %(expectedValue, outputValue))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:16,代码来源:Test_TwoDotFive_AddTwoNonReversedIntegersAsLinkedLists.py

示例13: test_without_carry_best_case_equal_elements_three_in_length

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [as 别名]
    def test_without_carry_best_case_equal_elements_three_in_length(self):
        firstList = SinglyLinkedList()
        secondList = SinglyLinkedList()
        outputList = SinglyLinkedList()

        firstList.populate([1, 1, 8])
        secondList.populate([4, 3, 1])

        s = Solution(firstList, secondList, outputList)
        s.addTwoNonReversedIntegersAsLinkedListsAndCreateNewList()

        outputValue = outputList.returnLinkedListAsList()

        expectedValue = [5, 4, 9]
        self.assertTrue(outputValue == expectedValue, "Expected: %s, Got: %s" %(expectedValue, outputValue))
开发者ID:prab-pip,项目名称:IntPrep,代码行数:17,代码来源:Test_TwoDotFive_AddTwoNonReversedIntegersAsLinkedLists.py

示例14: test_delete_head_on_empty_list

# 需要导入模块: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList import SinglyLinkedList [as 别名]
# 或者: from MyLibrary.LinkedLists.SinglyLinkedLists.SinglyLinkedList.SinglyLinkedList import returnLinkedListAsList [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.returnLinkedListAsList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。