Skip to content

Added Queue represented from list #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions data_structures/QueueOnList.py
Original file line number Diff line number Diff line change
@@ -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 put(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 get(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 size(self):
return self.length



Empty file added other/anagrams.txt
Empty file.