File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,17 @@ def __init__(self):
4
4
self .entries = []
5
5
self .length = 0
6
6
7
+ def __str__ (self ):
8
+ printed = '<' + str (self .entries )[1 :- 1 ] + '>'
9
+ return printed
10
+
7
11
"""Enqueues {@code item}
8
12
@param item
9
13
item to enqueue"""
10
14
def put (self , item ):
11
15
self .entries .append (item )
12
16
self .length = self .length + 1
13
- print ( self . entries )
17
+
14
18
15
19
"""Dequeues {@code item}
16
20
@requirement: |self.length| > 0
@@ -22,6 +26,13 @@ def get(self):
22
26
self .entries = self .entries [1 :]
23
27
return dequeued
24
28
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
+
25
36
"""Enqueues {@code item}
26
37
@return item at front of self.entries"""
27
38
def front (self ):
@@ -30,6 +41,3 @@ def front(self):
30
41
"""Returns the length of this.entries"""
31
42
def size (self ):
32
43
return self .length
33
-
34
-
35
-
You can’t perform that action at this time.
0 commit comments