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
3
votes
1answer
60 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....
2
votes
2answers
85 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
1answer
56 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
2answers
101 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
1answer
395 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
0answers
118 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
2answers
179 views

dynamic queue implementation in C++

I've implemented a dynamic queue with a random-access iterator. iterator: ...
0
votes
0answers
113 views

Asynchronously Iterable Queue Implementation for JavaScript

While studying Deno which is a kind of Node with everything normalized to modern JS and TS, I quickly met the; ...
5
votes
1answer
103 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 ...
1
vote
2answers
97 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 ...
0
votes
1answer
124 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 ...
2
votes
2answers
322 views

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

If you simply implement it with .push() to .enqueue() and .shift() to ...
4
votes
2answers
112 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 ...
1
vote
0answers
23 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 ...
2
votes
1answer
54 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 ...
2
votes
1answer
92 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 ...
5
votes
1answer
104 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 ...
2
votes
2answers
69 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 ...
7
votes
1answer
208 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 ...
5
votes
1answer
184 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 ...
6
votes
1answer
70 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, ...
2
votes
1answer
69 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 ...
0
votes
0answers
15 views

Calculate 1-based index after making certain operations on a Queue

Here's the problem statement You're given a list of n integers arr, which represent elements in a queue (in order from front to back). You're also given an integer x, and must perform x iterations of ...
4
votes
1answer
139 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 ...
6
votes
1answer
72 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 ...
1
vote
0answers
38 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 ...
3
votes
1answer
106 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 ...
4
votes
1answer
126 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 ...
1
vote
0answers
39 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 ...
1
vote
0answers
21 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 ...
1
vote
1answer
301 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 ...
1
vote
1answer
260 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/...
2
votes
2answers
66 views

Queue By Using Stack

I have implemented a queue by using a stack data structure. How could I improve it? ...
3
votes
1answer
225 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. ...
0
votes
1answer
57 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? ...
4
votes
1answer
308 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 ...
-2
votes
1answer
232 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 ...
2
votes
1answer
62 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. ...
3
votes
4answers
2k 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, ...
8
votes
3answers
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,...
2
votes
0answers
215 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 ...
3
votes
1answer
154 views

Simple queue on F#

...
6
votes
0answers
195 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. ...
6
votes
1answer
4k 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. ...
1
vote
0answers
123 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 ...
7
votes
3answers
128 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 ...
7
votes
2answers
68 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 ...
0
votes
1answer
293 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 ...
4
votes
2answers
210 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 ...
11
votes
3answers
3k 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() ...

1
2 3 4 5
8