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
5 votes
2 answers
123 views

Revised Job Queue for Strategy Game

After posting my previous question about this Job Queue, I decided I wasn't actually very happy with it. I am embarrassed to admit that upon further testing it did not function properly in all ...
bazola's user avatar
  • 8,569
13 votes
1 answer
2k views

Implementation of std::deque (obsolete)

Warning: This implementation is obsolete, because it doesn't meet the standard. Specifically, while the standard guarantee any pointers and references to elements to remain valid after insertion or ...
Dannyu NDos's user avatar
12 votes
5 answers
658 views

FiniteArrayQueue type with interface and unit tests

Doing some exercises on basic data structures, I learned about queues, and decided to roll my own to better understand how a basic queue can function. As the name indicates, this Queue is made from a ...
Phrancis's user avatar
  • 20.4k
11 votes
4 answers
1k views

Type-generic queue implementation using singly linked lists

Simple lightweight queue implementation using data size registration and singly linked lists as the underlying type Update #2 ...
Mode77's user avatar
  • 641
9 votes
2 answers
2k views

Concurrent FIFO in C++11

I have implemented a simple FIFO that can optionally be used by either a single thread or way to pass data between threads. The class is templated with arguments for the types the queue will contain ...
schrödinbug's user avatar
7 votes
3 answers
1k views

Lock-free multi-producer / multi-consumer queue in C++

I've been working on a lockless multi-producer, multi-consumer queue in an effort to learn as much as I can about concurrency, without the use of mutual exclusion. The queue uses a bounded ring buffer ...
Primrose's user avatar
7 votes
2 answers
1k views

MailQueue implementation with auto start - stop

Previous question was a little portion of the mailQueue. I finished the MailQueue, which has the ability to start and stop ...
chillworld's user avatar
  • 3,872
7 votes
1 answer
247 views

My queue implementation (in C) [V.2]

My previous implementation: My queue implementation (in C) I rewrote the queue following @vnp's suggestions. Here is the second version of it: Any suggestions or tips are appreciated :) (even tips ...
Michael Faraday's user avatar
6 votes
2 answers
178 views

(Rev. 2) Type-generic queue implementation using singly linked lists

Thanks to the extremely helpful comments and answers from the original post, I've improved the interface and implementation of this general-purpose queue library. Improvements include: Fixed memory ...
Mode77's user avatar
  • 641
6 votes
1 answer
231 views

(Optionally Concurrent) FIFO

Based on Concurrent FIFO in C++11 and my review I implemented a queue and its concurrent pendant. Is there anything left to improve regarding clarity, usability, code-style, lock-times or general ...
Deduplicator's user avatar
  • 19.1k
6 votes
2 answers
4k views

A simple queue implementation in Haskell

I'm a member of a discord channel and sometimes people post simple coding exercises for fun. This time the exercise was: Implement the following operations of a queue using stacks. push(x) -- Push ...
Michel Vorwieger's user avatar
6 votes
1 answer
89 views

My queue implementation (in C)

This is my queue implementtion in C. Feel free to ask me any questions relating to my code. Any tips or suggestions are welcome, including tips on naming/spacing/common conventions. Queue_node, Queue, ...
Michael Faraday's user avatar
5 votes
3 answers
178 views

Job Queue for Strategy Game

I've posted a revised version of this here. I posted about this basic problem a while ago, and I got the recommendation to move the code for managing the Jobs of my game to another class. I have ...
bazola's user avatar
  • 8,569
5 votes
1 answer
314 views

Double-ended queue for Embedded Systems

Following my previous question about a FIFO for embedded systems and the very detailed answer I got, I made some modifications to convert a simple FIFO to double-ended queue for Embedded Systems. It ...
MrBit's user avatar
  • 339
4 votes
2 answers
419 views

Worker AI and Job Queue Management for Simulation Game

So I've been working on AI for a Tower Building simulation game for quite a few days, and I think the code would really benefit from review. I'm a hobbyist programmer, but I really care about doing ...
bazola's user avatar
  • 8,569
4 votes
2 answers
5k views

ConcurrentLinkedQueue to unmodifiable list

I have a ConcurrentLinkedQueue where I put some mails in. Now I have a visual page where I want to see what's in the Queue, but ...
chillworld's user avatar
  • 3,872
4 votes
1 answer
910 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
4 votes
1 answer
540 views

Javascript Queue Object

I created a Queue object when answering this question and I was wondering if it could do with some improvement. Here is the current code: ...
Naftali's user avatar
  • 1,089
4 votes
4 answers
2k views

Class that implements a queue using two stacks

I am looking for a review of my code that implements a MyQueue class which implements a queue using two stacks. ...
user avatar
4 votes
2 answers
5k views

Robust logging solution to file on disk from multiple threads on serverside code

I have implemented a socket listener that runs on my Linux Ubuntu server accepting connections and then starting up a new thread to listen on those connections (classic socket listener approach). ...
dreza's user avatar
  • 6,437
4 votes
2 answers
187 views

DoublingQueue in Java

Inspired by this CR question, I decided to create my own queue! If you guys see anything taboo or have any improvements, please let me know. Ultimately I want it to be feature rich and bug free, with ...
T145's user avatar
  • 3,087
4 votes
1 answer
207 views

Constexpr circular queue

Below is a constexpr circular queue whose size is fixed. From what I tested the code seems to work exactly as expected of a queue. One advantage is how there's no dynamic allocations, so ignoring the ...
Steve Zhang's user avatar
3 votes
1 answer
143 views

Constexpr circular queue - follow-up #1

Follow up to my question here: Constexpr circular queue . I've taken the time to fix the many problems pointed out there and am asking for any tips/corrections for the new version below. The queue ...
Steve Zhang's user avatar
3 votes
1 answer
49 views

Singly-linked queue in PHP 7

I am learning PHP 7 and decided to implement a simple FIFO singly-linked queue in it: ...
coderodde's user avatar
  • 27.6k
3 votes
3 answers
10k views

Priority Queue in C#

I develop a small game using C# and need A* in it. For that, I need a PriorityQueue, which .NET does not have. I wanted to make my own one for practice. Here is it, please comment on performance and ...
PhilippHochmann's user avatar
3 votes
1 answer
3k views

MazeRunner in Java

To test the queue I perfected from one of my CR questions, I've developed a maze program that receives an input maze, starting and end positions, and solves it. I have separate software that handles ...
T145's user avatar
  • 3,087
3 votes
2 answers
295 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
3 votes
0 answers
623 views

Blocking Promise-driven queues with ECMAScript's async/await and generators

I implemented an AsyncQueue, whose dequeue() operation returns a Promise. The ...
ComFreek's user avatar
  • 751
2 votes
2 answers
877 views

JavaScript queue implementation using linked list

Are there better ways of modularizing the code? Does it contain things JavaScript experts would avoid? Is it idiomatic? Is there a better way of signaling an empty queue than returning ...
Douglas's user avatar
  • 859
2 votes
1 answer
56 views

Queue Interview Code basic methods made from struct Node optimized

Using feedback from my previous implementation I'm writing a very simple Queue of struct Nodes with only these methods get_front(), get_back(), pop_front(), push_back(), and a ostream friend method. I ...
greg's user avatar
  • 1,017
2 votes
4 answers
3k views

Maximum of all subarrays of size k

Given an array and an integer k, find the maximum for each and every contiguous subarray of size k. Examples: Input: arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6} k = 3 ...
JavaDeveloper's user avatar
2 votes
3 answers
123 views

Queue Interview Code basic methods made from struct Node

Thanks for all the feedback, I optimized the code here. Here I'm Writing a very simple Queue of struct Nodes with only these methods get_front(), ...
greg's user avatar
  • 1,017
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
1 vote
4 answers
688 views

Queue using doubly linked list

I have implemented my queue based on doubly linked list. The codes is tested and works, however, I am interested in some improvement ideas, thanks Based on some review remarks on my previous ...
V_head's user avatar
  • 525
1 vote
1 answer
724 views

Find pairs of consecutive numbers fetched from blocking queues

I was coding for the following programming question: Suppose you have two independent blocking queues that will keep getting new data, the new data will always be greater than the last element of ...
zokland's user avatar
  • 95
1 vote
2 answers
1k views

Generic Queue data structure in C++

I am a mathematician attempting to become proficient with C++. At the moment I am learning about data structures. I am now writing a queue data structure using linked list from scratch. I have tested ...
Snorrlaxxx's user avatar
0 votes
1 answer
523 views

FIFO queue for a 2D array in ANSI C

I have a 2D array of fixed size and I've implemented a FIFO function. So, the array will always be full before it reaches the FIFO function, then the FIFO will remove the oldest array, move all of the ...
ChrisD91's user avatar
  • 113
-1 votes
1 answer
845 views

Thread-safe queue mechanism

Is it my queue mechanism thread safe? I just wonder if I need concurrent collections. Need I lock Enqueue method? Console displays queue count in incorrect order, Does it affect on maxQueueCount at ...
dMilan's user avatar
  • 155
-1 votes
1 answer
432 views

Command line multipart or single file downloader

I am looking for a code review for this multipart or single file chunk downloader using threading and queues. downloader.py ...
Ciasto piekarz's user avatar