本文整理匯總了Python中LinkedList.LinkedList.addLast方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.addLast方法的具體用法?Python LinkedList.addLast怎麽用?Python LinkedList.addLast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.addLast方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LinkedList
# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import addLast [as 別名]
from LinkedList import LinkedList
list = LinkedList()
# Add elements to the list
list.add("America") # Add it to the list
print("(1)", list)
list.insert(0, "Canada") # Add it to the beginning of the list
print("(2)", list)
list.add("Russia") # Add it to the end of the list
print("(3)", list)
list.addLast("France") # Add it to the end of the list
print("(4)", list)
list.insert(2, "Germany") # Add it to the list at index 2
print("(5)", list)
list.insert(5, "Norway") # Add it to the list at index 5
print("(6)", list)
list.insert(0, "Poland") # Same as list.addFirst("Poland")
print("(7)", list)
# Remove elements from the list
list.removeAt(0) # Remove the element at index 0
print("(8)", list)
list.removeAt(2) # Remove the element at index 2