本文整理汇总了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