本文整理匯總了Python中LinkedList.LinkedList.print_list方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.print_list方法的具體用法?Python LinkedList.print_list怎麽用?Python LinkedList.print_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.print_list方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import print_list [as 別名]
def test():
lst = LinkedList()
lst.push(7)
lst.push(6)
lst.push(5)
lst.push(4)
lst.push(3)
lst.push(2)
lst.push(1)
lst.print_list()
swapNodes(lst.head, 4, 3)
lst.print_list()
示例2: LinkedList
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import print_list [as 別名]
slow = circular_list.head
# Since fast is k nodes from the start of the cycle as well,
# moving both pointers one node at a time would cause them to
# meet at the beginning of the cycle
while fast != slow:
fast = fast.next
slow = slow.next
return fast
if __name__ == "__main__":
list_vals = ["E", "D", "C", "B", "A"]
circular_list = LinkedList()
for val in list_vals:
circular_list.add_node(val)
ptr = circular_list.head
while ptr.next is not None:
ptr = ptr.next
circular_list.print_list()
ptr.next = circular_list.head.next.next
cycle_start = find_loop_start(circular_list)
print cycle_start.data