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
25
votes
4 answers

what's the proper way to use a ThreadPool?

If my understanding of the way the ThreadPool works is correct, one of its purposes is to limit the number of worker threads within a process that can be created at a given time. For example, if you set MaxThreads to 5 and then call…
John Smith
  • 4,416
  • 7
  • 41
  • 56
25
votes
1 answer

python multiprocessing: some functions do not return when they are complete (queue material too big)

I am using multiprocessing's Process and Queue. I start several functions in parallel and most behave nicely: they finish, their output goes to their Queue, and they show up as .is_alive() == False. But for some reason a couple of functions are not…
CPBL
  • 3,783
  • 4
  • 34
  • 44
25
votes
6 answers

PHP How do I implement queue processing in php

I want the data sent by my clients (via post) to be placed in a queue and a php script on my server first checks if the queue is empty. If the queue is not empty, then the script shall process all the data in the queue one by one.How do I do this?
ASHUTOSH
  • 862
  • 1
  • 10
  • 17
24
votes
8 answers

Access c++ queue elements like an array

Can queue elements be accessed like an array? If not, then what containers similar to a queue can?
neuromancer
  • 53,769
  • 78
  • 166
  • 223
24
votes
7 answers

Is there a "queue" in MATLAB?

I want to convert a recursive function to a iterative one. What I normally do is, I initialize a queue, put the first job into queue. Then in a while loop I consume jobs from queue and add new ones to the queue. If my recursive function calls itself…
nimcap
  • 10,062
  • 15
  • 61
  • 69
24
votes
3 answers

Use of the terms "queues", "multicore", and "threads" in Grand Central Dispatch

I am trying to get my head around the concepts of Grand Central Dispatch. I want to understand these quotes from Vandad's book on Concurrent Programming. The real use for GCD is to dispatch tasks to multiple cores, without making you the…
Cescy
  • 1,921
  • 3
  • 18
  • 21
24
votes
7 answers

When to use queue over arraylist

One basic argument to use a Queue over an ArrayList is that Queue guarantees FIFO behavior. But if I add 10 elements to an ArrayList and then iterate over the elements starting from the 0th element, then I will retrieve the elements in the same…
Victor
  • 16,609
  • 71
  • 229
  • 409
24
votes
9 answers

how bad is it to use dynamic datastuctures on an embedded system?

So in an embedded systems unit, that i'm taking at uni next year, we will learn that dynamic data structures are a bad thing to have in an embedded system program. but the lecture notes don't go into why. Now i'm working on a moderate scale,…
Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
24
votes
2 answers

Stack, foreach, wrong order?

When using Java's foreach syntax, Stack doesn't use LIFO ordering on the outputted elements. Consider the following code: import java.util.Queue; import java.util.Stack; import java.util.LinkedList; public class QueueStackTest { private static…
durron597
  • 31,968
  • 17
  • 99
  • 158
24
votes
15 answers

How do I chain or queue custom functions using JQuery?

I have multiple functions the do different animations to different parts of the HTML. I would like to chain or queue these functions so they will run the animations sequentially and not at the same time. I am trying to automate multiple events in…
orandov
  • 3,256
  • 3
  • 32
  • 32
23
votes
3 answers

Can queue::pop return a value now?

I know std::queue::pop() returns void. For two reasons: exception safety: something might throw after removing the element to be able to return the value by reference Fine. Now if I understand the new C++11 move semantics correctly, the second is…
Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
23
votes
5 answers

how do i find a complete list of available torque pbs queues?

Q: How do I find the available PBS queues on the "typical" Torque MPI system? (asking our admin takes 24+ hours, and the system changes with constant migration) (for example, "Std8" is one possible queue) #PBS -q Std8
russian_spy
  • 6,465
  • 4
  • 30
  • 26
23
votes
2 answers

pthread synchronized blocking queue

I'm looking for a recommended implementation of a thread-safe blocking queue (multi producer/consumer) in C using pthread synchronization semantics.
Mike
  • 58,961
  • 76
  • 175
  • 221
23
votes
2 answers

What is the significance of Application URL in laravel 5

in Config/app.php in laravel source, what is the actual use of url ? It says Application URL to be used by artisan command line tool , so what should it be actually? I mean should it be http://mydomainname.com or should it be /var/www/laravel/ or…
echoashu
  • 912
  • 3
  • 14
  • 31
23
votes
3 answers

Python: Writing to a single file with queue while using multiprocessing Pool

I have hundreds of thousands of text files that I want to parse in various ways. I want to save the output to a single file without synchronization problems. I have been using multiprocessing pool to do this to save time, but I can't figure out…
risraelsen
  • 253
  • 1
  • 2
  • 5