class Queue(object): def __init__(self): self.items = UnorderedList() def isEmpty(self): return self.items.isEmpty() def enqueue(self, item): self.items.add(item) def dequeue(self): return self.items.pop() def size(self): return self.items.size()
class Stack(object): def __init__(self): self.items = UnorderedList() def isEmpty(self): return self.items.isEmpty() def push(self, item): self.items.add(item) def pop(self): return self.items.pop(0) def peek(self): return self.items.head.getData() def size(self): return self.items.length
class Deque(object): def __init__(self): self.items = UnorderedList() def isEmpty(self): return self.items.isEmpty() def addFront(self, item): self.items.add(item) def addRear(self, item): self.items.append(item) def removeFront(self): return self.items.pop(0) def removeRear(self): return self.items.pop() def size(self): return self.items.length
def __init__(self): self.items = UnorderedList()
def testMyList(n): l2 = UnorderedList() for i in range(n): l2.add(n) for i in range(n): l2.pop(0)