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
0 votes
0 answers
48 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
  • 26.7k
3 votes
2 answers
58 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
  • 488
6 votes
1 answer
297 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
84 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
  • 26.7k
4 votes
1 answer
79 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 ...
RARA's user avatar
  • 205
7 votes
2 answers
748 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
199 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
  • 515
4 votes
1 answer
93 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
448 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
  • 315
6 votes
2 answers
159 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
  • 619
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
  • 619
2 votes
1 answer
66 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
114 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
1k 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
57 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
45 views

Sending events to the API via queue functionality

I am working on the queue which requirements are: We can 3 types of events (start, heartbeat which will be added to the queue in 5sec intervals, and the end event) Backup the events in local storage ...
Robson's user avatar
  • 163
0 votes
0 answers
201 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
357 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
71 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
1k 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
860 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
52 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
1 vote
1 answer
292 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
541 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
81 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
  • 121
4 votes
3 answers
537 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
5 votes
1 answer
6k 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
  • 319
5 votes
3 answers
451 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
75 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
490 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
575 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
231 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
4k 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
212 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
385 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
455 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
166 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
443 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
1k 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
535 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
1 vote
0 answers
106 views

Breadth first search of a binary-tree with channels

As an exercise in using channels in Go I implemented a breadth-first traversal of a binary tree, using a channel as a queue to store the order of the nodes to traverse. After ironing out a bunch of ...
LLlAMnYP's user avatar
  • 111
2 votes
1 answer
71 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
319 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
151 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
  • 329
7 votes
1 answer
241 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
265 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
  • 329
6 votes
1 answer
86 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
240 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
594 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

1
2 3 4 5
9