本文整理汇总了Python中LinkedList.LinkedList.removeFront方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.removeFront方法的具体用法?Python LinkedList.removeFront怎么用?Python LinkedList.removeFront使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.removeFront方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Queue
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import removeFront [as 别名]
class Queue(LinkedList):
'Queue implemented as a Linked List - FIFO'
# ctor
def __init__(self):
self.queue = LinkedList()
# enqueue element into back of queue
def enqueue(self, val):
self.queue.insertBack(val)
# dequeue element from front of queue
def dequeue(self):
deqVal = self.queue.head.data
self.queue.removeFront()
return deqVal
# print out the queue
def printQueue(self):
self.queue.printLL()
示例2: Stack
# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import removeFront [as 别名]
class Stack(LinkedList):
'Stack implemented as a Linked List - LIFO'
# ctor
def __init__(self):
self.stack = LinkedList()
# push element to top of stack
def push(self, val):
self.stack.insertFront(val)
# pop element from top of stack
def pop(self):
popVal = self.stack.head.data
self.stack.removeFront()
return popVal
# show the top element in stack
def peek(self):
print self.stack.head.data
# print out the stack
def printStack(self):
self.stack.printLL()