As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [queue]

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

Filter by
Sorted by
Tagged with
7 votes
3 answers
4k views

Fixed-size array-based implementation of a queue

For my computer science class, I've implemented a Java version of a queue and would like to know if there's anything wrong with it. After my tests, it seems to work fine, but maybe somebody can point ...
Maxbit's user avatar
  • 173
1 vote
1 answer
5k views

Smart Pointers Queue Implementation

To practice around with C++11 smart pointers I was trying to implement a simple Queue to go beyond a simple Linked List. The fact that the _first and ...
user49428's user avatar
1 vote
0 answers
340 views

Queue that permits at most X simultaneous operations

I ran into this once (permits=N) and then again today (permits =1) where I only want 1 to N operations running simultaneously. One example comes from firing into a state machine (the permit=1 example)...
Dean Hiller's user avatar
5 votes
0 answers
180 views

Concurrent Queue using Ada SPARK with the Ravenscar profile

See here: https://gitlab.com/linted/linted/blob/162b5e9fba53a90b3c6d78e214776e069c3c722b/src/ada-core/src/linted-queues.adb The code implements a concurrent queue. It can't allocate memory or use ...
Molossus Spondee's user avatar
2 votes
2 answers
981 views

Single producer single consumer command queue

I needed to create commands simply with lambda and execute it in another thread. The following code works fine. Any suggestions about performance are appreciated. I want to use SSE aligned variables ...
UPO33's user avatar
  • 31
7 votes
4 answers
611 views

Double-ended queue and iterators

I have created a double-ended container, but I have doubts about its efficiency in terms of performance. Can you please criticize the code? What can be done extra, such as shortening it? ...
Rıfat Tolga Kiran's user avatar
6 votes
2 answers
1k views

Insert and Remove Element in Deque using threads in C++

The following code works fine for inserting and removing an element from a deque using two threads. I would appreciate any help on how to make it better, especially in terms of thread safety. ...
tamraj_kilvish's user avatar
8 votes
6 answers
1k views

Implement queue using two stacks

Although it's a well-known algorithm, I thought to implement it from the perspective of a coding interview. I want to know if I can improve my code somehow. So, given the time constraint, is this a ...
CodeYogi's user avatar
  • 5,087
5 votes
2 answers
1k views

Linked-list-based stack and queue

This is my first attempt at building a linked-list-based stack and queue. It is the result of ~90 minutes of trying to implement some of what we're being taught in Algorithms class. I would like ...
blitzilla's user avatar
2 votes
1 answer
279 views

Popup message queueing

I have a WPF application where I have a function for generating an overlaying info grid. I have written some code for queueing the messages(IpopupMessage) so that each displays a certain amount of ...
Sondre's user avatar
  • 123
2 votes
1 answer
3k views

Implementing a queue using a circular buffer

I'm working on implementing a queue using a circular buffer problem. Any smarter ideas for better time complexity, any code bug or code style advice are highly appreciated. ...
Lin Ma's user avatar
  • 3,443
8 votes
2 answers
49k views

Writing a thread-safe queue in C++

I created a SafeQueue class, which stores pointers. It has two methods: push: Adds a new pointer to the queue next: If the queue is empty, returns nullptr. ...
Iter Ator's user avatar
  • 271
1 vote
3 answers
6k views

Time-delayed function queue

I recently had an interesting requirement in a test environment where I needed to simulate actions at varied (random) intervals in a node back-end. They needed to ...
pulse0ne's user avatar
  • 155
4 votes
2 answers
7k views

Implementation of std::deque

In the prior obsolete implementation of std::deque, I used two std::vectors to contain the elements. But the standard guarantees that pointers and references to elements aren't invalidated when an ...
Dannyu NDos's user avatar
3 votes
0 answers
59 views

Python simulacrum of windows copy window

I wrote a program to copy files with an progress bar that looks similar to Windows built in function. The copy function is run in a separate thread and the tkinter GUI is run in the main thread. This ...
jakethemc's user avatar
2 votes
1 answer
317 views

Templated double ended queue (deque) move semantics edge cases C++

My original deque implementation and efficiency question lacked move semantics. After ratchet freak provided an example of how to define them I decided to try adding them to my deque. The unit test + ...
TOM__'s user avatar
  • 105
3 votes
2 answers
2k views

C++ concurrent queue and testing

I've written concurrent queue based on std::queue. ...
TPlant's user avatar
  • 131
4 votes
1 answer
870 views

Template double ended queue (deque) implementation using dynamic allocation C++

I have written my own deque class to get a better grasp of C++ pointers and memory management. The following code is part of a larger 2D isometric game I am developing. It compiles and runs fine using ...
TOM__'s user avatar
  • 105
5 votes
1 answer
7k views

Semaphore based concurrent work queue

There's a need to have a mechanism in place that will process messages received from the network concurrently. However, only X number of messages can be allowed to be processed concurrently and there'...
Ostati's user avatar
  • 153
2 votes
2 answers
1k views

FIFO Queue Implementation

My Implementation of a FIFO queue. I am mainly curious about my initialization of empty generic arrays. ...
jacksonecac's user avatar
8 votes
4 answers
6k views

Animal Shelter in Java

I have been working my way through the problems in the book Cracking the Coding Interview. The instructions were to maintain an animal shelter that operates on a first in, first out basis (i.e. it is ...
Average's user avatar
  • 841
1 vote
1 answer
902 views

Job queue with threading

On many articles and blogs, I have read that exceptions should not decide flow of your code. I have wrote the following code using one thread: ...
Bhushan's user avatar
  • 113
1 vote
2 answers
945 views

Implementing a queue using three stacks

This is just for fun so you will see tons of print statements for trouble shooting. I was hoping on slimming this down some and gain new ideas on what I have. This was a challenge question in a class ...
jermiah's user avatar
  • 115
1 vote
2 answers
7k views

C++ thread safe queue implementation

I'm using this class for producer-consumer setup in C++: ...
UnTraDe's user avatar
  • 183
4 votes
3 answers
15k views

Implementing a generic Queue in C

I wrote a generic Queue that could with work any data type you give it. The Queue can do any the basic operations that you would expect a ...
Luis Averhoff's user avatar
1 vote
2 answers
495 views

Deque Implementation in Java

Please review my Deque implementation in Java and suggest ways of improving this. ...
Sandeep Kumar's user avatar
2 votes
1 answer
1k views

My own Queue Implementation in Java

Please review my Queue implementation and let me know if you have any suggestions. I am not returning an exception for any of the methods defined here. As we know ...
Sandeep Kumar's user avatar
3 votes
0 answers
3k views

Checking number of messages in jms queue code

I need to check number of messages in a jms queue for that i am using queuebrowser. Actually i have 2 queues. I check if there are more then 10 messages in second queue then the first queue should not ...
kirti's user avatar
  • 163
1 vote
1 answer
10k views

Generic Queue (Array and Linked List) Implementation

I am working on brushing up my data-structures knowledge, and was hoping to have my code/thoughts reviewed. Interface: ...
user3610520's user avatar
4 votes
2 answers
1k views

Array-based queue implementation

Here I have implemented a queue. Is this a correct, efficient queue implementation? what issues are there if any and what can be done to make it better? ...
jillian's user avatar
  • 95
2 votes
1 answer
622 views

Implementation of Queue using Linkedlist in Java

Can someone please review my code? Is it the correct implementation of a queue? If not, please give suggestions on how to implement it using a linked list. ...
nik7's user avatar
  • 23
3 votes
3 answers
5k views

C++ Queue Implementation

so I wrote a queue implementation in c++ and even though I know the code probably isn't as robust as it should be and probably doesn't perform all the checks it should, I'd like to know mostly if ...
Tiberiu Savin's user avatar
4 votes
3 answers
410 views

C Threadsafe Priority Queue O(log n) push, O(1) pop

I wrote this for an A* implementation: (pqueue.c) ...
JavaProphet's user avatar
4 votes
2 answers
137 views

Designing stack and queue from scratch in C

As a beginner and curious guy I'm interested in implementing data structures and algorithms from scratch. Here's my implementation of Stack and Queue, the most fundamental data structures. Are ...
ph03n1x's user avatar
  • 127
3 votes
1 answer
183 views

Receptive map queue

I've written a class I call ReceptiveMapQueue. Its purpose is to organize the internal structure of an AFKable RPG. It only has two public methods - dumping entries ...
corsiKa's user avatar
  • 660
2 votes
0 answers
271 views

Request Queue for League of Legends API

I am working on some website for League of Legends statistics, which uses the RiotGames API. The API allows you to do a maximum amount of requests per 10 seconds, and another maximum amount of ...
Danmoreng's user avatar
  • 121
4 votes
1 answer
587 views

Implement a queue using two stacks

I tried to implement a queue using two stacks. I saw there are questions about this topic, but in my example, I used build-in stack from java. My question is, can someone give me some advice to make ...
Sengngy Kouch's user avatar
4 votes
2 answers
131 views

Implementation of a queue for digicode-like system

What it is about I created an application where you need to push invisible buttons in a certain order to unlock the advanced mode. To handle this, I wanted to use a queue (FIFO) of my own, adapted to ...
BusyAnt's user avatar
  • 639
3 votes
1 answer
694 views

Queue class with enqueue and dequeue

I am just learning swift and tried to make a queue class with enqueue and dequeue. The node holds the data for each element The enqueue adds an element to the "queue" The dequeue deletes the first ...
Sigils's user avatar
  • 133
2 votes
2 answers
346 views

Finding the Least Common Ancestor of a Binary Tree

Input a binary tree (the root node) and 2 other nodes that need to be assessed for finding the least common ancestor (LCA) Code: a. Finding the nodes first with either ...
Neelesh Salian's user avatar
3 votes
2 answers
289 views

Queue using Stack

I implemented this solution for the problem. Please provide feedback and review if this can be improved in any way. ...
Neelesh Salian's user avatar
2 votes
3 answers
3k views

C++ fixed-size queue full/empty signaling

I'm considering an application where a large data needs to be written to file often. I would like to use a queue and have a producer and consumer running on different threads. Additionally, I would ...
johnnymopo's user avatar
4 votes
2 answers
6k views

Queue resizing array implementation

After learning about linked list implementations of a queue I was asked to try a resizing array implementation. I'm looking for constructive criticism. ...
Rocky's user avatar
  • 43
3 votes
1 answer
104 views

Queue implementation using two stacks

Here's my code and I want to know if there's a better method for doing so. While the question has stated two stacks I wonder if we could do only with one as well? ...
Mona Jalal's user avatar
3 votes
3 answers
3k views

Array-based queue implementation using C

I wrote this header for generic use of a queue. The one thing I'm wondering is if I understood the usage of void*. I hope that if somebody teach me some conventions ...
kidkkr's user avatar
  • 347
1 vote
1 answer
2k views

Pipeline with std::thread vectors and queue

here is my code, it works but after few iterations it slows down and stop without any error, I'm looking for a more efficient solution. ...
CIVI89's user avatar
  • 13
5 votes
1 answer
2k views

Implementing Binary Tree using Queue in C#

I am in the process of learning data structures and I am trying to implement Binary Tree using Queue in C#. Below are my Tree implementation classes. ...
djpanda's user avatar
  • 151
1 vote
1 answer
149 views

My Queue implementation is correct?

I have read CLRS Introduction to Algorithms book, now I'm on Elementary data structure chapter. I read about queue concept and try to implement in c. I have tested a lot it work fine, but I have a ...
Hari Haran's user avatar
2 votes
2 answers
1k views

Stack and Queue implemented with a LinkedList

I am looking for feedback on my implementations of Queue, Stack, and LinkedList using Java ...
Jared's user avatar
  • 721
3 votes
1 answer
312 views

MazeRunner in Java - follow-up

I've refined a lot of the code from my previous question, and have also decided to include the logic that interprets a given text file. Any advice on how to improve the actual algorithm that solves ...
T145's user avatar
  • 3,045

1
3 4
5
6 7
9