Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit 13dd4a1

Browse files
committed
Added toString and rotate
1 parent 78f99d2 commit 13dd4a1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

data_structures/QueueOnList.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ def __init__(self):
44
self.entries = []
55
self.length = 0
66

7+
def __str__(self):
8+
printed = '<' + str(self.entries)[1:-1] + '>'
9+
return printed
10+
711
"""Enqueues {@code item}
812
@param item
913
item to enqueue"""
1014
def put(self, item):
1115
self.entries.append(item)
1216
self.length = self.length + 1
13-
print(self.entries)
17+
1418

1519
"""Dequeues {@code item}
1620
@requirement: |self.length| > 0
@@ -22,6 +26,13 @@ def get(self):
2226
self.entries = self.entries[1:]
2327
return dequeued
2428

29+
"""Rotates the queue {@code rotation} times
30+
@param rotation
31+
number of times to rotate queue"""
32+
def rotate(self, rotation):
33+
for i in range(rotation):
34+
self.put(self.get())
35+
2536
"""Enqueues {@code item}
2637
@return item at front of self.entries"""
2738
def front(self):
@@ -30,6 +41,3 @@ def front(self):
3041
"""Returns the length of this.entries"""
3142
def size(self):
3243
return self.length
33-
34-
35-

0 commit comments

Comments
 (0)