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
23
votes
6 answers

Delete messages in service broker queue

I'd like to clear my queue in SQL Server Management Studio, but I don't want to delete the whole queue just the content in the queue (the messages).
senna
  • 319
  • 1
  • 4
  • 12
22
votes
2 answers

why is Stack a class while Queue is a Interface?

I think they are very similar...And when do we need to use stack or queue, why not just use ArrayList or LinkedList to replace them?
Yang
  • 406
  • 3
  • 9
22
votes
10 answers

How to cancel queued job in Laravel or Redis

How can I browse all the pending jobs within my Redis queue so that I could cancel the Mailable that has a certain emailAddress-sendTime pair? I'm using Laravel 5.5 and have a Mailable that I'm using successfully as follows: $sendTime =…
Ryan
  • 22,332
  • 31
  • 176
  • 357
22
votes
9 answers

A priority queue which allows efficient priority update?

UPDATE: Here's my implementation of Hashed Timing Wheels. Please let me know if you have an idea to improve the performance and concurrency. (20-Jan-2009) // Sample usage: public static void main(String[] args) throws Exception { Timer timer =…
trustin
  • 12,231
  • 6
  • 42
  • 52
22
votes
1 answer

Minimal example of TAILQ usage out of library

Can some one provide minimal example of TAILQ usage out of linux system library with explanation in c which can be compiled using gcc in Linux?
Khamidulla
  • 2,927
  • 6
  • 35
  • 59
22
votes
2 answers

Priority queue with higher priority first in Python

I need a priority queue that gets the item with the highest priority value first. I'm currently using the PriorityQueue Class from the Queue library. However, this function only returns the items with the lowest value first. I tried some ugly…
Ashok
  • 1,079
  • 3
  • 10
  • 17
22
votes
3 answers

Initializing Queue or Stack with default values?

You can Initialize a list with pre-placed values: List L1 = new List {1, 2, 3}; is there an equivalent of above for Queue? My idea was : Queue Q1 = new Queue {1, 2, 3}; which doesn't work. Is there any workaround? Is Queue
thkang
  • 11,215
  • 14
  • 67
  • 83
22
votes
4 answers

limit size of Queue in C++

I notice the thread of similar question: Limit size of Queue in .NET? That's exactly what I want to do, but I am not using .net but GNU C++. I have no reference to the base class in GNU C++, so java like super.***() or .net like base.***() will…
Lily
  • 5,872
  • 19
  • 56
  • 75
22
votes
8 answers

Is there a better way to wait for queued threads?

Is there a better way to wait for queued threads before execute another process? Currently I'm doing: this.workerLocker = new object(); // Global variable this.RunningWorkers = arrayStrings.Length; // Global variable // Initiate process foreach…
Zanoni
  • 30,028
  • 13
  • 53
  • 73
22
votes
3 answers

Is it possible to use Go's buffered channel as a thread-safe queue?

I want to find a queue structure (a data container) whose elements must be first-in-first-out. It is important for me that the structure must be thread-safe. I'm going to use this data container as something like a task or connection pool. I know a…
hardPass
  • 19,033
  • 19
  • 40
  • 42
21
votes
5 answers

Java BlockingQueue with batching?

I am interested in a data structure identical to the Java BlockingQueue, with the exception that it must be able to batch objects in the queue. In other words, I would like the producer to be able to put objects into the queue, but have the consumer…
Nico Huysamen
  • 10,217
  • 9
  • 62
  • 88
21
votes
4 answers

Signal queuing in C

I have a simple program under Linux which sends SIGUSR1 signal to its child process in a cycle. But when I send e.g. 10 signals, sometimes happens, that the child received only 3 of them. Last sent signal is always SIGUSR2 and that is received every…
Peter Krejci
  • 3,182
  • 6
  • 31
  • 49
21
votes
3 answers

How to work threading with ConcurrentQueue

I am trying to figure out what the best way of working with a queue will be. I have a process that returns a DataTable. Each DataTable, in turn, is merged with the previous DataTable. There is one problem, too many records to hold until the final…
IAbstract
  • 19,551
  • 15
  • 98
  • 146
21
votes
2 answers

Redis vs Kafka vs RabbitMQ for 1MB messages

I am currently researching a queueing solution to handle medium sized messages of 1MB. Besides the features differences between Redis, Kafka and RabbitMQ I cannot find any good answer to their performance on messages of size around 1MB. Any of you…
Slava Shpitalny
  • 3,965
  • 2
  • 15
  • 22
21
votes
4 answers

Cannot instantiate the type Queue. Why is this?

This is my main method for a stacks/queues assignment. I keep getting an error with my queue, but not my Stack. The stack class seems to be working just fine. I'm completely stuck. It says "cannot instantiate type Queue". Any help would be most…
Shuijiao
  • 211
  • 1
  • 2
  • 3