Skip to content

Commit

Permalink
Fix LinkedListQueue enqueue and dequeue
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyota committed Sep 24, 2017
1 parent 2910351 commit ac0b726
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions queue/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ def enqueue(self, value):
if not self.front:
self.front = node
self.rear = node
node.next = self.rear
self.rear = node
else:
self.rear.next = node
self.rear = node
self.top += 1

def dequeue(self):
Expand All @@ -98,7 +99,9 @@ def dequeue(self):
value = self.front.value
if self.front is self.rear:
self.front = None
self.front = self.front.next
self.rear = None
else:
self.front = self.front.next
self.top -= 1
return value

Expand Down

0 comments on commit ac0b726

Please sign in to comment.