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
5 votes
1 answer
2k views

dqueue - A dynamic FIFO queue library for C

This is the first draft of dqueue, a dynamic queue library written in C, with a sample program to demonstrate it. This is my first time writing any sort of library to be used as a generic subsection ...
jess's user avatar
  • 1,368
5 votes
1 answer
2k views

Mirror a stack of Integers

Write a method mirror that accepts a stack of integers as a parameter and replaces the stack contents with itself plus a mirrored version of itself (the same ...
cody.codes's user avatar
  • 1,945
0 votes
1 answer
2k views

Check if a stack of Integers contains a sequence of consecutive values

Write a method isConsecutive that takes a stack of integers as a parameter and that returns whether or not the stack contains a sequence of consecutive integers ...
cody.codes's user avatar
  • 1,945
4 votes
1 answer
6k views

Best way of implementing a circular buffer

I wanted to implement a circular buffer for learning purpose only. My first option was to use a secondary status for rear and front pointers: (Like the ones I've seen in many websites) ...
shark's user avatar
  • 43
1 vote
0 answers
856 views

Socket server with consumer-producer design to handle concurrent connections

The usual way is to implement socket server to handle concurrent requests by creating new thread for each request. Instead of this approach i tried to create a server using ...
benjamin c's user avatar
2 votes
2 answers
556 views

Blocking List/Queue while object that matches expression is enqueued [closed]

Based on Marc Gravell's BlockingQueue I wanted to know if there is a way to wait for an object that meets an expression. I have coded a method 'TryDequeueWhere' I am not sure if there is something ...
Franki1986's user avatar
4 votes
1 answer
3k views

Create an implementation of Deque (double-ended queue) with linked list nodes

I encountered this question as I am preparing for my code interview. Using Python, create an implementation of Deque (double-ended queue) with linked list nodes that has attributes of both front ...
NinjaG's user avatar
  • 2,469
5 votes
3 answers
324 views

Reimplementation of Python's deque

It has been a while since taking the class Algorithms and Data Structures, so the following module was written as an exercise for implementing Python's ...
Noctis Skytower's user avatar
2 votes
1 answer
61 views

JavaScript Queue Attempt #2

This is a follow-up review to JavaScript queue implementation using linked list I've run the code through a linter, fixed every style error, added const where it ...
Douglas's user avatar
  • 859
2 votes
2 answers
851 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
4 votes
3 answers
758 views

A deque for up to one million elements

I have a task where I need to write my own deque and to this code was executed for 1 second, I get a result of 1.09 sec. The max count of elements is 1000000. How can I optimize it for better ...
Denis Sologub's user avatar
1 vote
2 answers
245 views

Heap space issue with queue

I need some help with this code which is giving me a heap space issue. I have tried executors too but still I get out of memory issue. The consists of a queue which initially holds an endpoint. The ...
v1shnu's user avatar
  • 133
3 votes
2 answers
1k views

Implementation of a Resizing Array Queue

Below is a problem from Sedgewick's Algorithms and my solution. Any thoughts or suggestions for improvement would be much appreciated. Develop a class that implements the queue abstraction with a ...
albertjorlando's user avatar
1 vote
1 answer
3k views

Yet Another multithreaded FIFO queue written in C++17

Here, I have written a simple FIFO multithreaded queue with following features (if I have implemented correctly): Thread safe Supports multiple container types (given that they provide some function) ...
jnbrq -Canberk Sönmez's user avatar
4 votes
3 answers
157 views

Implementation of a simple stack with min method

The problem statement: Implement a stack which has push and pop method and also min method whereas min method has \$O(1)\$ complexity. From an interview standpoint, what mistakes would you point ...
PnotNP's user avatar
  • 219
5 votes
1 answer
1k views

Non blocking single producer/consumer queue with C++11 atomics

I've recently got interested in lockless programming, mainly lockless queues for job repartitions, so here I undertook a challenge of creating lockless queue for single producer and consumer. This is ...
FanciestBanana's user avatar
1 vote
2 answers
5k views

Queue Implemented as Single Linked List

Note: I do know that Python libraries provide a Linked list and Stack. This implementation has been done to practice Python and some of the data structures and algorithms. I have implemented Queue as ...
BlooB's user avatar
  • 293
4 votes
2 answers
686 views

Pausing and resuming a concurrent database update queue

I have a class DatabaseQueue which asynchronously runs SQLite updates that it takes from a LinkedBlockingQueue. I implemented a ...
kmecpp's user avatar
  • 143
5 votes
2 answers
2k views

Bounded Queue with multiple consumers and multiple producers

It was an interview question: Should implement a class - BlockingQueue with those constraints: 2 Methods - Adding an item and Take an item from the queue. The class should support multiple consumers ...
David Michaeli's user avatar
2 votes
2 answers
1k views

Simple Queue Implementation

Purpose As I've never implemented a queue, I decided to create a very simple implementation using a linked list approach. Discussion I create a singly linked list, using a ...
Jae Bradley's user avatar
  • 1,835
1 vote
0 answers
1k views

Load balancing consumer and producer with multiprocessing

Tasks are distributed to producer in multiple worker process. Results from workers are sent through Queue to a ...
hamster on wheels's user avatar
3 votes
1 answer
2k views

Work stealing queue

I implemented work stealing queue inspired by Sean Parent's talk on code::dive 2016. Full implementation is here. I am looking to get feedback on improvements to make code more effective and common ...
Viktor's user avatar
  • 143
4 votes
2 answers
11k views

Fixed Size Queue

I have written a simple fixed size queue and am looking to get feedback on best practices. Specifically, handling unintended behaviors e.g. construct with negative size. This is not for a specific ...
Sam's user avatar
  • 41
5 votes
1 answer
2k views

Message Queue for inter-thread communication

I wrote this little piece of code, a while back. The intention behind it was to create a system to send messages between consumer and producer threads. I have no idea for what i wanted to use it. I ...
Mischa's user avatar
  • 185
1 vote
1 answer
62 views

Demonstration of processing a queue of no-op threads

I am creating a script, that will SSH to several hosts, get stuff, parse it and return. Because I wait for server response, I'm using threading. Real script is ...
G.Gabunia's user avatar
  • 109
0 votes
1 answer
3k views

Queue/stack/node class Implementation

Below there are 3 short header files for queue, stack, and node implementation. I do ...
BlooB's user avatar
  • 293
1 vote
1 answer
827 views

Hackerrank "Queues: A Tale of Two Stacks" Javascript Solution

Here is the original problem, and below is my solution (passing). It's asking to implement a queue with 2 stacks, which means I cannot simply use Array.shift. I wonder if the solution can be improved. ...
kdenz's user avatar
  • 335
1 vote
1 answer
702 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
4 votes
1 answer
3k views

Blocking queue implementation with std::unique_ptr

I implemented, somewhat closely based on this implementation, a blocking queue with emphasis on filling up first. So if one producer and one consumer thread are using the queue, the producing queue ...
Jonas K's user avatar
  • 43
2 votes
3 answers
2k views

Notifying consumers when a producer is done

I am writing a simple program with a producer and a few consumers: the producer pushes to a queue some integers, and the consumers pop elements from the queue and print them (order doesn't matter). ...
noamgot's user avatar
  • 123
16 votes
4 answers
2k views

String Queue implementation

Is the implementation clean enough & can be used in production? I tried to write clean & bug-free code. It looks good to me. I would appreciate any improvement suggestions. One question I ...
Pollob's user avatar
  • 163
6 votes
1 answer
223 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
  • 18.5k
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
6 votes
2 answers
232 views

Stack and Queue Linked List Implementations

I'm relatively new to C as a language, but I wouldn't call myself a beginner. That being said, I don't believe my C "coding style," so to speak, is particularly developed. Also, I'm new to error ...
robbie's user avatar
  • 261
3 votes
1 answer
2k views

Max-Heap arraylist based priority queue written in Java

I have a program that I'm writing that needs to use a priority queue as part of an algorithm. I specifically need to order (String, Integer) pairs for example (Bread, 3), (Beer, 5), (Eggs,2), etc. I'...
j.jerrod.taylor's user avatar
1 vote
0 answers
2k views

Array based Queue Implementation using Templates

This is my first code using templates and I wanted to know if the code looks good? I have some doubts like what's the best way to report error to user (queue full/empty), I checked a link online http:...
zorro's user avatar
  • 61
2 votes
3 answers
6k views

Queue implementation using linked list

I have implemented a queue data structure using linked list in C#. I have also associated my implementation with unit tests. Is this implementation correct? Any suggestion? ...
Joan Dimko's user avatar
4 votes
1 answer
3k views

Lock-free FIFO queue implementation

...
ShadowStar's user avatar
1 vote
0 answers
107 views

Implementation of Dequeue data structure

I have just started learning to code for interviews and I would like to request a code review of a "Dequeue" data structure. I could not find any implementation anywhere to compare it to. I would like ...
manoflogan's user avatar
5 votes
2 answers
1k views

Linked deque implementation in C

I wrote a deque implementation in C for storing char *. It uses a doubly linked list, but I'm calling it a deque since it can only push/pop from the head and tail ...
LT_'s user avatar
  • 151
1 vote
1 answer
1k views

dequeue() in Queue implememtation that uses a circular linked list

I use a circular linked list to implement a queue, and it only holds one last (note that ...
chenzhongpu's user avatar
5 votes
2 answers
801 views

Object pool pattern for asynchronous socket operations

I have written my own object pool class called ObjectPool<T> which uses SpinLock and ...
Svek's user avatar
  • 1,023
6 votes
1 answer
3k views

Queue with multiple consumers and one producer

I've written a queue supporting one producer and multiple consumer threads. The idea is that the queue instances a definable number of long running consumer threads. Internally I'm using a ...
Moerwald's user avatar
  • 163
6 votes
1 answer
140 views

JavaScript Queue

I'm new to JS and have I made this snippet for practicing. Because I have no idea for JS conventions, I want some advice about that. ...
kidkkr's user avatar
  • 347
0 votes
1 answer
1k views

Turn a non-blocking concurrent queue into a blocking concurrent queue

Microsoft Visual Studio offers a non-blocking concurrent queue class, concurrency::concurrent_queue, based on Intel's TBB. I am using this as a base for a blocking ...
Jamerson's user avatar
  • 303
3 votes
1 answer
317 views

TCP retarder for network delay simulation

I would like to simulate delay over network, for that I have implemented a simple retarder (=introduce random delay while maintaining order of messages) using Boost to handle sending itself. It ...
wondra's user avatar
  • 143
8 votes
2 answers
608 views

Sending data to a database in size-limited chunks

I have a method which takes a parameter which is Partition enum. This method will be called by multiple background threads around same time period by passing ...
david's user avatar
  • 1,647
1 vote
0 answers
63 views

Counting dropped frames while converting uncompressed video data

I am writing a class for converting uncompressed video data which processes data in its incoming queue and stores them in its outgoing queue. Every time it tries to process a frame of a format it ...
muXXmit2X's user avatar
  • 313
1 vote
2 answers
178 views

Basic implementation of an array-based Queue

After been taught about Queues in lecture I've tried to do my own implementation. I like to mention: The ideas were shown in lecture on a blackboard using a pseudocode notation. The following code ...
michael.zech's user avatar
  • 3,990
4 votes
2 answers
177 views

My implementation of Stack and Queue with Array without help of library functions

I am new to Java and am trying to learn coding. Here is my implementation of a stack and a queue without the help of library functions. Please provide your suggestions on design, coding style and ...
SLR's user avatar
  • 139

1 2 3
4
5
9