Last active
June 27, 2020 21:38
-
-
Save terror/d6d51cd8d157fb93ddd05132e7f2c0af to your computer and use it in GitHub Desktop.
Python queue standard lib
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
import queue | |
items = [1,2,3,4,5] | |
q = queue.Queue() | |
# Enqueue elements | |
for i in items: | |
q.put(i) | |
# Dequeue and return element from the queue | |
item = q.get() | |
# Get size of queue (int) | |
q_size = q.qsize() | |
# Check if empty queue (bool) | |
is_empty = q.empty() | |
# Check if queue is full (bool) | |
is_full = q.full() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment