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
6 votes
3 answers
631 views

Redefining queue with different front and rear

...
Sai_krishna's user avatar
0 votes
0 answers
90 views

Simulation: Find a waiting queue order that minimizes the total waiting time - Java

Intro Suppose we are given a queue of waiting times \$\langle t_1, \ldots, t_n\rangle\$. The first "person" \$(t_1)\$ leaves the queue immediately. The persons \$(t_i), i > 1\$ all have ...
coderodde's user avatar
  • 27k
3 votes
2 answers
80 views

Enhancing a non-multithreaded Circular buffer

Looking to get some feedback on a simple non-multithreaded circular buffer. Ideally, I'd want to have a logic to prevent the data from getting overwritten but couldn't find a reasonable way. For ...
xyf's user avatar
  • 508
6 votes
1 answer
386 views

Synchonizing queue with mutex

I am trying to syncronize the queue between threads using mutex. I have 2 mil random integers in input.txt file. Main thread reads integers then puts them in queue. Other threads are simultaneously ...
EternalLlama's user avatar
1 vote
1 answer
110 views

Queue-mergesort: a mergesort that does optimal number of comparisons in the worst case in Java

Here is the code for queue-mergesort by Mordecai J. Golin and Robert Sedgewick: com.github.coderodde.util.QueueMergesort.java: ...
coderodde's user avatar
  • 27k
4 votes
1 answer
181 views

Blocking Queue Class Unit Test

I would like any feedback on making the unit test for a BlockingQueue class more robust or better? improvements to the coding style, use of the ...
KetDog's user avatar
  • 209
7 votes
2 answers
812 views

ThreadSafe std::queue

I have written a threadsafe queue and I would like you to suggest what can be improved and how to write good unit tests for this implementation. ...
Edziju's user avatar
  • 299
1 vote
4 answers
574 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
4 votes
1 answer
115 views

Queue implemented using two stacks in Swift

I need your expert opinion! In fact, for a Leetcode Problem, I had to code a queue using 2 stacks. It's shown just below and functions well. It is a pretty simple code with peek, pop, push, etc. ...
Thomas H.'s user avatar
4 votes
1 answer
837 views

Asynchronous file writer : queue, mutex, condition variable

As we know, it is better to write to a disk in a separate thread because the bottleneck may be the disk, which is slower than the CPU (at the condition only one thread writes to the disk). So I have ...
rafoo's user avatar
  • 325
6 votes
2 answers
174 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
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
2 votes
1 answer
68 views

Queue Linked List based implementation in C++

I wrote my implementation to Queue Linked List based. And I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account. ...
Omar_Hafez's user avatar
2 votes
2 answers
130 views

Queue array based implementation in C++

I wrote my implementation to Queue array based. And I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account. Thanks in advance. ...
Omar_Hafez's user avatar
1 vote
0 answers
2k views

Node.js batch processing

Batch processing steps: When a job is posted, push it to the queue. Get the required number of items from the queue and put it in the ...
sg7610's user avatar
  • 370
0 votes
1 answer
60 views

Queue-like class for managing stream data and metadata

The following class is used in an application to record internet radio streams*. These streams consist of big chunks of audio data with smaller chunks of metadata between them. By monitoring the ...
mindoverflow's user avatar
0 votes
0 answers
277 views

ASP.NET Core 6 background DB logger

In an application, many actions need to be logged in the database. but this logging process should not slow down the request. So they should be done in an asynchronous queue or something. This is my ...
Parsa99's user avatar
3 votes
0 answers
548 views

Async FIFO processing of database writes - naive implementation in .Net 6

One of the companies I was recently interviewing with gave me a following task to implement in a day or two using .Net, just to see where my coding abilities are at: Implement a Web API that gets ...
mi105's user avatar
  • 31
1 vote
1 answer
77 views

daemon in a producer-consumer

The daemon program is associated with a message queue with a predefined key, to be blocked later when waiting for messages. The two programs implement a producer-...
Mike's user avatar
  • 299
2 votes
1 answer
2k views

C++14 Lock-free Multi-producer, Multi-Consumer Queue

Introduction This is a follow-up to a previous question of mine, where I presented another queue of the same type to get some feedback on it. Some people pointed out some fundamental errors I had ...
Primrose'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
0 votes
1 answer
53 views

Type-agnostic abortion condition in Producer-Consumer model queue

This is a follow-up post to the topic discussed here. Description I am trying to implement a robust, multi-threaded producer-consumer model with a single producer in the main thread and several ...
DocDriven's user avatar
  • 161
3 votes
2 answers
374 views

Optimize Leetcode 239. Sliding Window Maximum using Swift

LeetCode problem 239. Sliding Window Maximum You are given an array of integers nums, there is a sliding window of size k which ...
Shawn Frank's user avatar
2 votes
0 answers
699 views

Multi-producer/single-consumer queue in Python

I am currently working on a problem that involves multiple producers and a single consumer through a queue object. The following list is about a few things that's special about this problem: One ...
dhu's user avatar
  • 327
2 votes
1 answer
89 views

Merging and sorting queue/list implementation

My requirement is implementing a Queue<T> (where T is a Lexeme) that is capable of ...
LppEdd's user avatar
  • 119
4 votes
3 answers
639 views

FIFO array/queue

I'm new to programming and was tasked with programming a generic circular FIFO queue, without using anything but an underlying array and self-programmed methods. I still don't know how to approach ...
deutschistschwer's user avatar
8 votes
1 answer
9k views

Thread-safe message queue

In my learning course, I've implemented a message queue to which data gets pushed by some thread and later gets processed by some other thread. My implementation isn't that efficient as it involves ...
Harry's user avatar
  • 379
5 votes
3 answers
479 views

Randomized Queue with ArrayList from Princeton's Algorithm Book

In the book they recommend to utilize an Array, but I think that it's easier to use an ArrayList instead, is there any problem with that? Is this code well designed? ...
Enzo Yasuo's user avatar
3 votes
1 answer
88 views

Merging pages together into an append log

Situation I'm scraping data from a paginated list on a website to be sent out as notifications. For the most part we'll only need to scape the first page and handle additions, deletions and duplicates....
Phroggie's user avatar
2 votes
2 answers
498 views

Write deduplicated 9-digit numbers from concurrent clients to a log

Problem Statement: Write a server (“Application”) in Java that opens a socket and restricts input to at most 5 concurrent clients. Clients will connect to the Application and write any number of 9 ...
ProgrammingHandyman's user avatar
2 votes
1 answer
992 views

The multithreading model to clean ConcurrentQueue in C#

I have some code that populate EventfulConcurrentQueue which is ConcurrentQueue. So I need to save all data from ...
DmitryBoyko's user avatar
3 votes
2 answers
324 views

Generic concurrent bounded buffer in C

I just implemented a generic concurrent queue in C, and I'd like some feedback on my implementation, as well as the logic in handling generic data and concurrency. buffer.h ...
Samuele B.'s user avatar
6 votes
1 answer
5k views

Compute the outputs of a generator in parallel

I am processing an unknown "length" of generator object. I have to keep things "lazy" because of memory management. The processing is compute heavy, so writing it multiproc style ...
Potter A's user avatar
2 votes
0 answers
241 views

Fixed-width non-FIFO DispatchQueue

I have implemented a custom concurrent queue on top of GCD which offers two additional pieces of functionality: Limit the maximum number of concurrently executing tasks. Give manual control over ...
Marcel Tesch's user avatar
0 votes
2 answers
428 views

dynamic queue implementation in C++

I've implemented a dynamic queue with a random-access iterator. iterator: ...
dammi's user avatar
  • 3
5 votes
1 answer
533 views

Generic Queue in C

I'm implementing a generic (ie. void *) queue in C. I believe I have a working version but I'm looking for two things: Do any subtle bugs pop out to the ...
sdasdadas's user avatar
  • 557
1 vote
2 answers
189 views

FIFO queue for a 2D array in ANSI C, version 2

This is a modification of my previous version. I would like advice on improving a FIFO algorithm for a 2D array that I've developed in ANSI C. I have written code that uses this algorithm for test ...
ChrisD91's user avatar
  • 113
0 votes
1 answer
501 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
2 votes
2 answers
2k views

Queue with O(1) enqueue and dequeue with JS arrays

If you simply implement it with .push() to .enqueue() and .shift() to ...
Redu's user avatar
  • 856
4 votes
2 answers
835 views

Type agnostic, statically allocated, thread-safe queue in C

I need a queue in C for an embedded application in which I cannot allocate memory dynamically. I avoided using void* for the queue elements (which is not convenient ...
Sparkler's user avatar
  • 309
2 votes
1 answer
80 views

Basic queue design and implementation

In general, I'd love some comments on this basic queue using dynamic allocation. In particular, I want comments about whether this queue is good in embedded systems, for example say a a sensor network ...
Adeesh Lemonickous's user avatar
2 votes
1 answer
1k views

A thread-safe blocking FIFO queue

A legacy project was upgraded from legacy code that used either SystemV FIFO device (or similar queue on Windows platform) which was deeply ingrained into every thread's implementation. Following ...
Swift's user avatar
  • 123
4 votes
1 answer
445 views

C++ Queue Circular Array Implementation

I'm trying to implement a queue data structure in C++ using a circular array. Please give recommendations on how I can improve this code. Also, is my array growth strategy good? I'm doubling the array ...
Guy on the Internet's user avatar
1 vote
2 answers
184 views

Double-ended queue for Embedded Systems with different data size

I decided to modify my last code about a queue intended for embedded systems and make it accept different data types for multiple purposes. It is a double-ended queue, the user can store and get ...
MrBit's user avatar
  • 339
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
5 votes
1 answer
299 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
6 votes
1 answer
88 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
2 votes
1 answer
294 views

Multiple producer single consumer on the same thread

I implemented a multi-producer single consumer class, with an important restriction that once the consumer started working, it must continue its work on the same thread (the reasoning behind this is ...
Ron Klein's user avatar
  • 1,157
4 votes
1 answer
807 views

A concurrent lock-free Linked Queue implementation

Recently I've been learning about concurrency/parallelism and I decided to implement the Michael&Scott lock-free Linked queue (PDF) as practice. I'm not entirely sure how to test this data ...
chromaticc's user avatar
6 votes
1 answer
179 views

Extract text file from zip, parse content and post to azure queue storage

Problem I'm trying to create the most performant code to: Extract a text file from a zip parse its content serialize class post to Azure Queue Storage Scenario 4 times per year I receive 20 zip ...
Andy Schmitt's user avatar

1
2 3 4 5
8