Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Python Hybrid Stack/Queue Implementation
- #Sheldon Alman
- #sheldonalman at gmail.com
- class stackQueue(object):
- def __init__(self):
- self.stackQueue = list()
- def shift(self):
- return self.stackQueue.pop(0)
- def unshift(self, item):
- self.stackQueue.insert(0,item)
- def push(self, item):
- self.stackQueue.append(item)
- def pop(self):
- return self.stackQueue.pop(len(self.stackQueue)-1)
- def isempty(self):
- if len(self.stackQueue) == 0:
- return True
- else:
- return False
- #returns the first element of the data structure
- def peek(self):
- return self.stackQueue[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement