Questions tagged [queue]

A queue is an ordered, first-in-first-out data structure. Typical implementations of queues support pushing elements to the back and popping them off the front position.

  • A queue is not limited to a fixed capacity
    • A bounded queue is a queue limited to a fixed number of items
  • A doubly linked list is a good implementation choice

Operations

  • enqueue - pushes an element to the end of the queue
  • dequeue - pops an element from the front of the queue

See Also

Resources

Queue Wikipedia Article

11098 questions
122
votes
2 answers

Sharing a result queue among several processes

The documentation for the multiprocessing module shows how to pass a queue to a process started with multiprocessing.Process. But how can I share a queue with asynchronous worker processes started with apply_async? I don't need dynamic joining or…
alexis
  • 48,685
  • 16
  • 101
  • 161
120
votes
7 answers

Difference between stream processing and message processing

What is the basic difference between stream processing and traditional message processing? As people say that kafka is good choice for stream processing but essentially kafka is a messaging framework similar to ActivMQ, RabbitMQ etc. Why do we…
TechEnthusiast
  • 1,795
  • 2
  • 17
  • 32
107
votes
10 answers

How do I make and use a Queue in Objective-C?

I want to use a queue data structure in my Objective-C program. In C++ I'd use the STL queue. What is the equivalent data structure in Objective-C? How do I push/pop items?
MrDatabase
  • 43,245
  • 41
  • 111
  • 153
106
votes
17 answers

Is there a queue implementation?

Can anyone suggest Go container for simple and fast FIF/queue, Go has 3 different containers: heap, list and vector. Which one is more suitable to implement a queue?
rev
  • 1,063
  • 2
  • 8
  • 4
104
votes
10 answers

std::queue iteration

I need to iterate over std::queue. www.cplusplus.com says: By default, if no container class is specified for a particular queue class, the standard container class template deque is used. So can I somehow get to the queue's underlying deque and…
jackhab
  • 17,128
  • 37
  • 99
  • 136
103
votes
16 answers

Deleting queues in RabbitMQ

I have a few queues running with RabbitMQ. A few of them are of no use now, how can I delete them? Unfortunately I had not set the auto_delete option. If I set it now, will it be deleted? Is there a way to delete those queues now?
Phalgun
  • 1,468
  • 2
  • 15
  • 24
97
votes
5 answers

How do I set a number of retry attempts in RabbitMQ?

I am using RabbitMQ and I have a queue that holds email messages. My consumer service de-queues messages and attempts to send them. If, for any reason, my consumer cannot send the message, I would like to re-queue the message to send again. I…
user2689570
  • 1,331
  • 1
  • 11
  • 11
95
votes
17 answers

Get notification when NSOperationQueue finishes all tasks

NSOperationQueue has waitUntilAllOperationsAreFinished, but I don't want to wait synchronously for it. I just want to hide progress indicator in UI when queue finishes. What's the best way to accomplish this? I can't send notifications from my…
Kornel
  • 97,764
  • 37
  • 219
  • 309
94
votes
2 answers

How do I (succinctly) remove the first element from a slice in Go?

I've built a simple queue in Go. It uses an internal slice to keep track of its elements. Elements are pushed onto the queue by appending to the slice. I'd like to implement .Pop() by removing the first element in elements. In many other languages,…
Brian Gesiak
  • 6,648
  • 4
  • 35
  • 50
92
votes
5 answers

FIFO based Queue implementations?

I need a simple FIFO implemented queue for storing a bunch of ints (I don't mind much if it is generics implementation). Anything already baked for me in java.util or Trove/Guava library?
Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294
90
votes
9 answers

C++11 thread-safe queue

A project I'm working on uses multiple threads to do work on a collection of files. Each thread can add files to the list of files to be processed, so I put together (what I thought was) a thread-safe queue. Relevant portions follow: // qMutex is a…
Matt Kline
  • 10,149
  • 7
  • 50
  • 87
87
votes
5 answers

"OSError: [Errno 17] File exists" when trying to use os.makedirs

I have several threads running in parallel from Python on a cluster system. Each python thread outputs to a directory mydir. Each script, before outputting checks if mydir exists and if not creates it: if not os.path.isdir(mydir): …
user248237
86
votes
4 answers

RabbitMQ - Message order of delivery

I need to choose a new Queue broker for my new project. This time I need a scalable queue that supports pub/sub, and keeping message ordering is a must. I read Alexis comment: He writes: "Indeed, we think RabbitMQ provides stronger ordering…
Bick
  • 17,833
  • 52
  • 146
  • 251
86
votes
9 answers

Best implementation of Java Queue?

I am working (in Java) on a recursive image processing algorithm that recursively traverses the pixels of the image, outwards from a center point. Unfortunately, that causes a Stack Overflow. So I have decided to switch to a Queue-based…
Georges Oates Larsen
  • 6,812
  • 12
  • 51
  • 67
85
votes
16 answers

How to iterate over a priority_queue?

Can I traverse a standard priority_queue or standard queue in c++ with an iterator (like a vector)? I don't want to use pop because it cause my queue to be dequeued. Thanks for any help
mina70
  • 851
  • 1
  • 6
  • 3