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
2 votes
1 answer
80 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 ...
user avatar
7 votes
3 answers
323 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 ...
user avatar
0 votes
1 answer
41 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 ...
user avatar
  • 161
1 vote
1 answer
152 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 ...
user avatar
2 votes
0 answers
211 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 ...
user avatar
  • 317
2 votes
1 answer
68 views

Merging and sorting queue/list implementation

My requirement is implementing a Queue<T> (where T is a Lexeme) that is capable of ...
user avatar
  • 121
4 votes
3 answers
328 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 ...
user avatar
5 votes
1 answer
1k 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 ...
user avatar
  • 247
5 votes
3 answers
384 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? ...
user avatar
0 votes
0 answers
117 views

Circular Resizing Array in Queue Impl [duplicate]

I am going through a course and after learning the theory I decided to implement the DS on my own. I write a few test cases and all operations seem to be working fine but once I tried to double check ...
user avatar
  • 1
3 votes
1 answer
69 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....
user avatar
2 votes
2 answers
267 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 ...
user avatar
2 votes
1 answer
124 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 ...
user avatar
3 votes
2 answers
138 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 ...
user avatar
6 votes
1 answer
2k 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 ...
user avatar
2 votes
0 answers
168 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 ...
user avatar
0 votes
2 answers
216 views

dynamic queue implementation in C++

I've implemented a dynamic queue with a random-access iterator. iterator: ...
user avatar
  • 3
5 votes
1 answer
239 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 ...
user avatar
  • 557
1 vote
2 answers
137 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 ...
user avatar
  • 113
0 votes
1 answer
284 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 ...
user avatar
  • 113
2 votes
2 answers
838 views

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

If you simply implement it with .push() to .enqueue() and .shift() to ...
user avatar
  • 777
4 votes
2 answers
207 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 ...
user avatar
  • 299
1 vote
0 answers
40 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 ...
user avatar
  • 111
2 votes
1 answer
57 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 ...
user avatar
2 votes
1 answer
449 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 ...
user avatar
  • 123
4 votes
1 answer
209 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 ...
user avatar
1 vote
2 answers
107 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 ...
user avatar
  • 319
7 votes
1 answer
217 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 ...
user avatar
5 votes
1 answer
211 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 ...
user avatar
  • 319
6 votes
1 answer
77 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, ...
user avatar
2 votes
1 answer
91 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 ...
user avatar
  • 1,157
4 votes
1 answer
248 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 ...
user avatar
6 votes
1 answer
83 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 ...
user avatar
1 vote
0 answers
40 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 ...
user avatar
3 votes
1 answer
122 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 ...
user avatar
4 votes
1 answer
152 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 ...
user avatar
1 vote
0 answers
46 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 ...
user avatar
  • 111
1 vote
0 answers
25 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 ...
user avatar
  • 389
1 vote
1 answer
543 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 ...
user avatar
1 vote
1 answer
447 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/...
user avatar
2 votes
2 answers
68 views

Queue By Using Stack

I have implemented a queue by using a stack data structure. How could I improve it? ...
user avatar
3 votes
1 answer
383 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. ...
user avatar
0 votes
1 answer
60 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? ...
user avatar
4 votes
1 answer
472 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 ...
user avatar
  • 143
-2 votes
1 answer
363 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 ...
user avatar
  • 97
2 votes
1 answer
63 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. ...
user avatar
  • 29
3 votes
4 answers
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, ...
user avatar
8 votes
3 answers
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,...
user avatar
  • 111
2 votes
0 answers
370 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 ...
user avatar
  • 235
3 votes
1 answer
213 views

Simple queue on F#

...
user avatar

1
2 3 4 5
8