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 votes
1 answer
66 views

Queue implementation in C# [closed]

I have tried to implement a queue from scratch, and it doesn't really seem to match what i found on internet, and I am wondering if this is a correct implementation, and what makes using Stack ...
3 votes
1 answer
115 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....
8 votes
1 answer
5k 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 ...
6 votes
3 answers
634 views

Redefining queue with different front and rear

...
1 vote
1 answer
112 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: ...
3 votes
2 answers
391 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 ...
0 votes
0 answers
96 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 ...
3 votes
2 answers
81 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 ...
6 votes
1 answer
411 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 ...
4 votes
1 answer
213 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 ...
7 votes
2 answers
845 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. ...
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 ...
5 votes
2 answers
2k views

Queue implementation using arrays

Please review the code: ...
4 votes
1 answer
137 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. ...
4 votes
1 answer
941 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 ...
8 votes
1 answer
10k 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 ...
6 votes
1 answer
2k views

A Thread-Safe FIFO in C99

I started a little weekend project to try and learn how to multithread with pure C99 and POSIX threads. The project is composed of three threads, input, processing, and output, which communicate with ...
7 votes
1 answer
8k views

Queue with std::vector

How can I improve this code? ...
2 votes
1 answer
85 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. ...
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 ...
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 ...
2 votes
2 answers
137 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. ...
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 ...
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 ...
0 votes
0 answers
332 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 ...
1 vote
1 answer
80 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-...
3 votes
0 answers
594 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 ...
5 votes
3 answers
494 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? ...
12 votes
4 answers
3k views

Animal shelter simulation using Queues

This is of one the interesting problems I've solved: An animal shelter holds only dogs and cats, and operates on a strictly "first in, first out" basis. People must adopt either the "oldest" (...
8 votes
1 answer
4k views

Calculate the running median

I'm trying to solve a challenge where you need to calculate the median every time you add a number. say you have a list of numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ...
6 votes
1 answer
560 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. ...
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 ...
4 votes
3 answers
809 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 ...
1 vote
3 answers
3k views

Deque implemented using a circular array

I found a tutorial on implementing a deque using a circular array. I changed the implementation but I am not sure if it is correct or not. So I have one question: I wrote code that uses an ...
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 ...
1 vote
1 answer
2k views

Deque implementation with array in Java

I'm trying to implement a deque data structure with an iterator in Java using array. Please help to review and point out things that I can improve on. ...
4 votes
2 answers
8k views

Implementation of std::deque

In the prior obsolete implementation of std::deque, I used two std::vectors to contain the elements. But the standard guarantees that pointers and references to elements aren't invalidated when an ...
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 ...
0 votes
1 answer
59 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 ...
2 votes
0 answers
753 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 ...
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 ...
4 votes
3 answers
683 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 ...
14 votes
4 answers
7k views

Circular Bounded Queue using C#

As an exercise, I have implemented a circular bounded queue using arrays as the base data structure. I'd appreciate it if someone can review it for me. ...
3 votes
2 answers
1k views

Python stack and queue classes, implemented using lists

I have made a stack and queue implementation with OOP in Python (sorry for variable names) . It is made from scratch. I just watched a video how these two things work. I am still trying to improve in ...
2 votes
2 answers
500 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 ...
2 votes
1 answer
1k 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 ...
3 votes
2 answers
356 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 ...
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 ...
2 votes
0 answers
250 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 ...
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 ...

1
2 3 4 5
8