Skip to content

Commit 607c280

Browse files
committed
collections.deque: Add initial implementation.
1 parent f099ae2 commit 607c280

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class deque:
2+
3+
def __init__(self, iterable=None):
4+
if iterable is None:
5+
self.q = []
6+
else:
7+
self.q = list(iterable)
8+
9+
def popleft(self):
10+
return self.q.pop(0)
11+
12+
def popright(self):
13+
return self.q.pop()
14+
15+
def pop(self):
16+
return self.q.pop()
17+
18+
def append(self, a):
19+
self.q.append(a)
20+
21+
def appendleft(self, a):
22+
self.q = [a] + self.q

0 commit comments

Comments
 (0)