Created
March 23, 2013 15:21
-
-
Save ashwin/5228081 to your computer and use it in GitHub Desktop.
How to implement a queue with maximum length in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Queue with max length of 3 | |
from collections import deque | |
q = deque( maxlen=3 ) | |
# deque([]) | |
q.append( 10 ) | |
q.append( 20 ) | |
q.append( 30 ) | |
# deque([ 10, 20, 30 ]) | |
q.append( 40 ) | |
# deque([ 20, 30, 40 ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment