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
1 vote
0 answers
49 views

Implementing a Queue with Small size optimization

I was trying to implement a queue implementing the small size optimization. I was wondering any ways I can make this code better (more performant, better code style, etc). It seems to work fine (in ...
Mihir Shah's user avatar
3 votes
1 answer
137 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
4 votes
1 answer
188 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
1 vote
0 answers
48 views

Run non overlapped periodical tasks on user specified executor

I have concurrency tasks in my module: user code is able to instantiate my object and specify Executor service, then user can submit requests to this object which ...
g4s8's user avatar
  • 111
1 vote
0 answers
33 views

regex on a log file utilizing stacks and queue's in Java

This would be for a MUD client, which has elements of a sort of telnet bot. Here, there's ...
Thufir's user avatar
  • 379
1 vote
1 answer
734 views

Concurrent Queue with enqueue and dequeue using Stack as underlying data structure

This is a mix of data structure and multi threading concept based question. (This is only for understanding and learning purpose) The language for the solution : Java A Queue with FIFO behavior needs ...
Krishna Kumar's user avatar
1 vote
1 answer
712 views

Implement jquery like functions addClass, removeClass and delay in Javascript

Assume $ is not the browser. Now have to implement $, it will take a string, which is a query, it will use the querySelector to select the element. (Reference: https://developer.mozilla.org/en-US/docs/...
Umang Gupta's user avatar
2 votes
2 answers
69 views

Queue By Using Stack

I have implemented a queue by using a stack data structure. How could I improve it? ...
Neslihan Bozer's user avatar
3 votes
1 answer
644 views

Thread safe reader-writer queue with C++11

Below is my honest attempt to write thread safe queue using C++11 features. Please review it and provide your comments. ...
Anand Shah's user avatar
0 votes
1 answer
79 views

Ensure queue is in ascending order

The program reads in a queue of integers and returns determines whether or not it is valid (ascending). How can this code be improved? I assume iterator include statement is unnecessary? ...
Darnoc Eloc's user avatar
4 votes
1 answer
641 views

Codility Fish (queue) programming challenge

Today I have attempted a Codility exercise "Fish" (https://app.codility.com/programmers/lessons/7-stacks_and_queues/fish/), and I have to say I found it to be: 1) Not necessarily "easy" as implied by ...
Greem666's user avatar
  • 143
-2 votes
1 answer
492 views

C++ generic task interface for delayed execution

I want to rework my current game-server engine to use some global queue of tasks which will be distributed through all the working threads. I started with task interface. I want it to be able to ...
Piodo's user avatar
  • 97
2 votes
1 answer
69 views

Is this breadth-first search correct?

I wrote a program that is supposed to be a breadth-first search algorithm, but I'm very new to search algorithm so I don't know if my method is very effective or if there is a simpler way to do this. ...
IsaacK0's user avatar
  • 29
3 votes
4 answers
3k views

Implementation of a deque using an array in Python 3

I created this double-ended queue using list. I supported the standard operations such as push, ...
Taimoor Ahmad's user avatar
8 votes
3 answers
1k views

Temporary queue to prevent duplication

I am making a Reddit bot and to prevent my bot from posting to the same comment twice, instead of making a database, I decided I would rather create a temporary list (or "queue") that once appended to,...
docyoda's user avatar
  • 111
2 votes
0 answers
600 views

MongoQ - A Task queue system using Mongo

I've been using Beanstaldk (not Amazon's one) for years and loved the possibility to handle delays and priorities in the tasks, but I recently had to filters the tasks for specific reasons, and ...
Cyril N.'s user avatar
  • 245
3 votes
1 answer
319 views

Simple queue on F#

...
Vlad Lutsenko's user avatar
6 votes
1 answer
487 views

Simple lock-free queue - multiple producers, single consumer

I have a simple lock-free queue, which supports multiple producers, but only one consumer. It is based on a constant-sized ring buffer and stores only pointers to a class and not actual instances. ...
Perl99's user avatar
  • 69
7 votes
1 answer
9k views

High Performance Blocking Queue C#

I am developing a high-performance(real-time) system, it requires message passing between its component. speed and accuracy is at most priority. I have explored a few options. ...
Arjun Vachhani's user avatar
1 vote
0 answers
172 views

Codewars Kata - Tickets Queue

The challenge: You managed to send your friend to queue for tickets in your stead, but there is a catch: he will get there only if you tell him how much that is going to take. And everybody can ...
jpolache's user avatar
  • 127
7 votes
3 answers
186 views

Very basic Integer queue in C

I've never written a queue before and literally just took the concepts and tried to code something up. I decided to write a basic integer queue and as an example/driver I use a queue of size 5 which ...
the_endian's user avatar
  • 1,333
7 votes
2 answers
88 views

TaskScheduler in python

I have found the need to schedule a few simple functions in a first-come-first-served way so I developed a small task scheduler based on multiprocessing and I thought it would be a good candidate for ...
bracco23's user avatar
  • 384
0 votes
1 answer
858 views

Create custom Queue class with O(1) Enqueue and O(1) Dequeue [closed]

I am implementing a Queue class in C# using a Node/LinkedList class that I also implemented, and I wonder if there is a way to implement the enqueue and the dequeue methods, both in algorithmic ...
Dani's user avatar
  • 121
4 votes
2 answers
254 views

Basic Queue in C++ Using Array

I wrote a queue class in C++ using arrays of fixed width. Could anyone review my code ? I would appreciate any comment and recommendations. It works like a circular queue, so I handled back and front ...
Erdem Tuna's user avatar
11 votes
3 answers
4k views

HackerRank Implement Queue using two stacks Solution

Challenge Problem Statement - Implement a Queue using two Stacks I implemented dequeue() in \$O(1)\$ at the cost of enqueue() ...
KshitijV97's user avatar
2 votes
0 answers
86 views

Lock-free pooled queue

I am attempting to create a lock free pool of resources and I need the ability to access any one that is not already accessed and then return it back when I do not need it. This will happen very very ...
Christopher Silvas's user avatar
3 votes
0 answers
159 views

msmq bulk send in c# [closed]

Please review the code below and provide constructive feedback to improve. Multiple threads call the SendMessageToMSMQ method to send messages to a msmq queue. ...
Sam's user avatar
  • 31
5 votes
1 answer
600 views

SQS subscriber pattern in background service

I have the below code to pull messages from a FIFO SQS queue. Using the while (IsRunning) loop makes me feel to question the code design. Is there a pattern I am ...
George Taskos's user avatar
7 votes
1 answer
95 views

Concurrent Queue Adapter

There's lots of code out there for basic adapters of std::deque to provide a thread-safe queue. I've adopted that, but wanted to provide a relatively full analog to ...
rsjaffe's user avatar
  • 253
8 votes
1 answer
4k views

Yet another multi-producer single consumer queue in C++17

Here's an implementation of a multi-producer single consumer queue that I wanted to use with tasks such as logging from multiple points in a program to a single sink. The implementation is inspired ...
Vilas Chitrakaran's user avatar
-4 votes
1 answer
78 views

Generic Custom STACK Class for Hanoi Problem in C# [closed]

I have created a custom class (Generic) in C# for the Hanoi problem. and I am not sure I did the correct thing. ...
Navin Kumar K Subramanian's user avatar
3 votes
0 answers
2k views

File-system based queue in python

I would like to implement a concurrent (multi-thread, multi-process) queue that is backed by file system. Data is pickled over a file, stored in a directory and given a sequential name. The ...
The Data Scientician's user avatar
2 votes
1 answer
55 views

Singly-linked queue in PHP 7 #2

I have improved this post to the code below. As always, any critique is much appreciated! ...
coderodde's user avatar
  • 26.7k
3 votes
1 answer
47 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
  • 26.7k
28 votes
4 answers
9k views

FIFO data structure in pure C

I programmed a generic queue in pure C and I'd love to receive some feedback from other programmers. You may use the following questions to guide your review. Is the API well thought and idiomatic? ...
Gabriel's user avatar
  • 1,053
7 votes
2 answers
615 views

Cyclic queue using an array

I tried to implement a cyclic Queue using an array, as a task from a coding interview. Please comment about style, as well as any edge cases I may have missed. ...
Gilad's user avatar
  • 5,311
8 votes
1 answer
590 views

JSON messaging queue with transformation and dispatch rules

I put together this code as part of a practice problem. The instructions for the program are to accept JSON messages, transform the messages and then dispatch them to the right queue according to a ...
Cauder's user avatar
  • 183
1 vote
0 answers
67 views

Puzzling SBCL Compiler Note

I’m having trouble understanding an SBCL compiler note about unreachable code in the following function. The referenced code is attempting to push a value into an Lparallel queue: ...
davypough's user avatar
  • 415
6 votes
1 answer
170 views

Implementing a queue: questions and clarification

Im trying to teach myself some computer science (and c++). I am relatively new to this (and to code review). I have attempted to implement a queue. I have copied the code below for reference. ...
Rafael Vergnaud's user avatar
2 votes
1 answer
1k views

Simple raw buffer queue implementation

I am trying to implement a simple raw queue in C++. This is what I have come up with ...
Ali's user avatar
  • 313
2 votes
1 answer
55 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
3 answers
121 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
4 votes
1 answer
268 views

Basic queue implementation in C

I'm practicing data structures in C and I implemented a queue based on its description: ...
aderchox's user avatar
  • 207
2 votes
0 answers
433 views

thread safe queue with interrupt function

I try to implement a thread safe queue with the interrupt function (interrupt all threads who are blocking to take data from queue). ...
szh's user avatar
  • 21
1 vote
1 answer
131 views

Queue implementation in ES6 [closed]

Here's my Queue implementation in ES6, ...
Melissa Stewart's user avatar
3 votes
2 answers
572 views

Circular Queue in C for an embedded project

I wrote a simple circular queue. (in order to store characters because of the fact, that I am using UART through the DMA and sometimes my printf's override each other) I am looking for some review, ...
Oliver Al-Hassani's user avatar
7 votes
1 answer
2k views

Custom implementation of python queue to use dict instead of dqueue

A bit of context: I have 100 addresses that can send transactions to a blockchain, and I have a web app that works like this: Get request and handle it in a thread Get a free address from the queue ...
Ron Serruya's user avatar
4 votes
1 answer
239 views

Node.JS Server Queue Processor

I implemented a simple queuing system for my Node.JS app and wanted a critique on it's structure. ...
Enijar's user avatar
  • 175
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
2 votes
2 answers
100 views

Simple array operation using a Queue

Question We are given an array (indexed from 1) of N elements on which we make M queries: add(Left, Right, X) - all the elements between the position Left and Right (1<=Left<=Right<=N) are ...
Michael's user avatar
  • 285

1
2
3 4 5
9