Queues
Python
There are 2 queues in Python:
queue.Queue
: intended for allowing different threads to communicate using queued messages/datacollections.deque
: intended as a data structure.
from collections import deque
q = deque()
q.append(1)
q.appendleft(0)
q.pop()
q.popleft()
Java
Queue<Object> queue = new LinkedList<>();
Summary of Queue methods
- Throws exception:
add(e)
,remove()
,element()
- Returns special:
offer(e)
,poll()
,peek()
Go
There's no built-in queues in Go, but we can use a channel:
c := make(chan int, 300)
//Push
c <- value
//Pop
x <- c