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
33
votes
5 answers

How to cast or convert List of objects to queue of objects

How can one convert a list of objects to a queue thereby maintaining the same order?
GigaPr
  • 5,206
  • 15
  • 60
  • 77
33
votes
2 answers

built-in max heap API in Python

Default heapq is min queue implementation and wondering if there is an option for max queue? Thanks. I tried the solution using _heapify_max for max heap, but how to handle dynamically push/pop element? It seems _heapify_max could only be used…
Lin Ma
  • 9,739
  • 32
  • 105
  • 175
33
votes
5 answers

Data Structures - Randomized Queues

I am currently working on the Queues assignment from Princeton's Algorithms Part I. One of the assignments is to implement a randomized queue. This is a question regarding the implementation and tradeoffs of using different data…
philosopher
  • 1,079
  • 2
  • 16
  • 29
33
votes
2 answers

celery - Tasks that need to run in priority

In my website users can UPDATE they profile (manual) every time he want, or automatic once a day. This task is being distributed with celery now. But i have a "problem" : Every day, in automatic update, a job put ALL users (+-6k users) on…
fabriciols
  • 959
  • 1
  • 12
  • 25
33
votes
5 answers

Thread safe queue - Enqueue / Dequeue

Firstly, i'll explain a short scenario; As a signal from certain devices triggers, an object of type Alarm is added to a queue. At an interval, the queue is checked, and for each Alarm in the queue, it fires a method. However, the problem i'm…
Kestami
  • 2,045
  • 3
  • 32
  • 47
32
votes
6 answers

Force Oracle to return TOP N rows with SKIP LOCKED

There are a few questions on how to implement a queue-like table (lock specific rows, selecting a certain number of them, and skipping currently locked rows) in Oracle and SQL Server. How can I guarantee that I retrieve a certain number (N) rows,…
Travis
  • 2,654
  • 4
  • 26
  • 46
32
votes
11 answers

Job has been attempted too many times or run too long

I have a job that works flawless locally, but in production I run into issues where it doesn't work. I've encompassed the entire handle() with a try/catch and am not seeing anything logged to Bugsnag, despite many other exceptions elsewhere from…
Ben
  • 60,438
  • 111
  • 314
  • 488
32
votes
5 answers

Deleting message from SQS FIFO queue: The receipt handle has expired

I switched to a FIFO queue and I got this error message when I tried to delete a message from the queue Value {VALUE} for parameter ReceiptHandle is invalid. Reason: The receipt handle has expired. It appears that the error happens because I tried…
doej
  • 449
  • 1
  • 5
  • 5
32
votes
8 answers

How do I implement a circular list (ring buffer) in C?

How do I implement a circular list that overwrites the oldest entry when it's full? For a little background, I want to use a circular list within GWT; so using a 3rd party lib is not what I want.
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
32
votes
2 answers

Scalability issue when using outgoing asynchronous web requests on IIS 7.5

A bit of a long description below, but it is a quite tricky problem. I have tried to cover what we do know about the problem in order to narrow down the search. The question is more of an ongoing investigation than a single-question based one but I…
Toby999
  • 584
  • 1
  • 5
  • 14
31
votes
9 answers

Clearing azure service bus queue in one go

We are using a service bus queue in our project. We are in need of a functionality to remove all the messages from the queue when the administrator chooses to clear the queue. I searched on the net but could not find any function which does this…
bhavesh lad
  • 1,242
  • 1
  • 13
  • 23
31
votes
5 answers

C# first class continuation via C++ interop or some other way?

We have a very high performance multitasking, near real-time C# application. This performance was achieved primarily by implementing cooperative multitasking in-house with a home grown scheduler. This is often called micro-threads. In this system…
Wayne
  • 2,959
  • 3
  • 30
  • 48
31
votes
1 answer

List vs Queue vs Set of collections in Java

what is the difference among list, queue and set?
Sumithra
  • 6,587
  • 19
  • 51
  • 50
31
votes
2 answers

How to stop/cancel/suspend/resume tasks on GCD queue

How to stop/cancel/suspend/resume tasks on GCD queue How does one stop background queue operations? I want to stop some screens in our app. And some screens it should be auto resume. So, how does one pass a queue in iOS? I mean when user have…
lakshmanbob
  • 311
  • 1
  • 3
  • 7
31
votes
4 answers

Efficient queue in Haskell

How can I efficiently implement a list data structure where I can have 2 views to the head and end of the list, that always point to a head a tail of a list without expensive calls to reverse. i.e: start x = [] end x = reverse start -- [] start1 =…
TheOne
  • 10,819
  • 20
  • 81
  • 119