Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#109 from RGauthamRam/patch-1
Browse files Browse the repository at this point in the history
Added front to indicate the starting of the Queue
  • Loading branch information
dynamitechetan authored Sep 5, 2017
2 parents 616faac + 7e26755 commit e4ef5d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions data_structures/Queue/QueueOnList.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Queue():
def __init__(self):
self.entries = []
self.length = 0
self.front=0

def __str__(self):
printed = '<' + str(self.entries)[1:-1] + '>'
Expand All @@ -22,8 +23,9 @@ def put(self, item):
item that was dequeued"""
def get(self):
self.length = self.length - 1
dequeued = self.entries[0]
self.entries = self.entries[1:]
dequeued = self.entries[self.front]
self.front-=1
self.entries = self.entries[self.front:]
return dequeued

"""Rotates the queue {@code rotation} times
Expand Down

0 comments on commit e4ef5d4

Please sign in to comment.