mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
Merge pull request #109 from RGauthamRam/patch-1
Added front to indicate the starting of the Queue
This commit is contained in:
commit
e4ef5d41cd
|
@ -3,6 +3,7 @@ class Queue():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.entries = []
|
self.entries = []
|
||||||
self.length = 0
|
self.length = 0
|
||||||
|
self.front=0
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
printed = '<' + str(self.entries)[1:-1] + '>'
|
printed = '<' + str(self.entries)[1:-1] + '>'
|
||||||
|
@ -22,8 +23,9 @@ class Queue():
|
||||||
item that was dequeued"""
|
item that was dequeued"""
|
||||||
def get(self):
|
def get(self):
|
||||||
self.length = self.length - 1
|
self.length = self.length - 1
|
||||||
dequeued = self.entries[0]
|
dequeued = self.entries[self.front]
|
||||||
self.entries = self.entries[1:]
|
self.front-=1
|
||||||
|
self.entries = self.entries[self.front:]
|
||||||
return dequeued
|
return dequeued
|
||||||
|
|
||||||
"""Rotates the queue {@code rotation} times
|
"""Rotates the queue {@code rotation} times
|
||||||
|
|
Loading…
Reference in New Issue
Block a user