Added Queue

This commit is contained in:
2016-10-08 21:12:14 -04:00
parent df8798416b
commit 9b2d32e8a3
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
"""Queue represented by a python list"""
class Queue():
def __init__(self):
self.entries = []
self.length = 0
"""Enqueues {@code item}
@param item
item to enqueue"""
def enqueue(self, item):
self.entries.append(item)
self.length = self.length + 1
print(self.entries)
"""Dequeues {@code item}
@requirement: |self.length| > 0
@return dequeued
item that was dequeued"""
def dequeue(self):
self.length = self.length - 1
dequeued = self.entries[0]
self.entries = self.entries[1:]
return dequeued
"""Enqueues {@code item}
@return item at front of self.entries"""
def front(self):
return self.entries[0]
"""Returns the length of this.entries"""
def length(self):
return self.length

0
other/anagrams.txt Normal file
View File