As of May 31, 2023, we have updated our Code of Conduct.

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
238 views

Job queue that performs actions

A brief background: I'm working on a game prototype for a simple strategy game. After I created a number of possible jobs I wanted to create something to manage them. This is the first time I've ...
bazola's user avatar
  • 8,579
8 votes
2 answers
3k views

Lockless Queue Multiple-Reader Singler-Writer in C++

I wrote a lockless queue for sending small objects from a single thread to a random worker thread. Assumptions: x86/x86_64 compiled with GCC one thread may Write(), multiple threads may Read() ...
Bob65536's user avatar
  • 852
4 votes
1 answer
2k views

Big-O complexity calculation for a merge and sort function

I have the following code which basically takes a list of sorted integer arrays and merges them together removing the duplicates. I have tried to do the complexity analysis and came to a rough ...
Tom's user avatar
  • 141
12 votes
3 answers
16k views

Tail implementation in C

Write the program tail, which prints the last n lines of its input. By default, n is 10, let ...
cristid9's user avatar
  • 1,271
4 votes
0 answers
446 views

Queue with "unlimited" buffer in Go

This is small piece of bigger puzzle, but usable by its own. It an attempt to have a nonblocking queue with "unlimited" (besides memory size) buffer length. Got unit-tests 100% statement coverage, it ...
canni's user avatar
  • 211
22 votes
1 answer
25k views

Thread-safe concurrent FIFO queue in C++

Is this the correct way to implement a thread-safe concurrent FIFO queue in C++? It requires passing unsigned char* arrays of binary data. Thread Safe Concurrent ...
PerracoLabs's user avatar
5 votes
1 answer
2k views

Optimization for add function in queue

I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code. Using Homework Questions as reference, as this is a homework related question. ...
Emz's user avatar
  • 1,024
12 votes
1 answer
15k views

Continuously receive messages async from Azure Service Bus Queues

I'd like to get input on my approach of continuously receiving messages from an Azure Service Bus queue using the async part of the library. My main concern being whether its "safe" to use Task....
sitereactor's user avatar
11 votes
2 answers
21k views

First-come first-serve job scheduling algorithm

I tried to make the code for implementation of first-come first-serve job scheduling algorithm as used by operating systems. How can I make it better? I am using turbo C++ compiler ...
vidit jain's user avatar
3 votes
1 answer
1k views

MemoryCache as a message broker?

I'm in the middle of a project that was built around Microsoft's Message Queue service. During development all of our machines are on a domain and we were able to create a public queue accessible from ...
B2K's user avatar
  • 208
10 votes
2 answers
10k views

Multi producer/consumer queue (without Boost) in C++11

Not lock-free, but still only C++11 and no Boost. It also supports timeouts. ...
GabiMe's user avatar
  • 395
3 votes
3 answers
10k views

Priority Queue in C#

I develop a small game using C# and need A* in it. For that, I need a PriorityQueue, which .NET does not have. I wanted to make my own one for practice. Here is it, please comment on performance and ...
PhilippHochmann's user avatar
5 votes
1 answer
2k views

Very simple priority queue

I wrote this code to handle a fixed number of priority levels. I believe performance will depend on the number of priority levels. Considering only a few levels (3 to 5), is there a more efficient ...
2013Asker's user avatar
  • 1,979
7 votes
1 answer
19k views

PriorityQueue<T> implementation

I was hoping to get some general feedback and thoughts about my implementation of a generic priority queue. Please feel free to be as critical as you want or see fit. Generic priority queue ...
David Venegoni's user avatar
5 votes
2 answers
3k views

Queue implementation in C

I was reading about opaque pointers and decided to try it with queues. Please review my code and let me know if there are any errors and how to improve code quality and performance. It uses lines to ...
2013Asker's user avatar
  • 1,979
3 votes
4 answers
949 views

A more efficient enqueue algorithm in Java

So I have this simple code in Java. It enqueue (adds) and element to the end of the queue (implemented by an ArrayList) without ...
MandM's user avatar
  • 31
1 vote
1 answer
110 views

FixedSizePriorityQueue for storing a max number of elements

I implemented the FixedSizePriorityQueue class. The intended purpose is that, you can add as many elements as you want, but it will store only the greatest ...
Murat's user avatar
  • 243
1 vote
1 answer
237 views

Can someone review my implementation of a Queue?

So here is my Queue interface: ...
letter Q's user avatar
  • 483
5 votes
2 answers
3k views

Implement data structure overflow queue

Implement data structure overflow queue. Overflow queue is a normal queue with one extra property. It never throw Stack overflow exception. So whenever queue becomes full, it replaces the oldest ...
MohdAdnan's user avatar
  • 223
1 vote
1 answer
5k views

Removing nodes from queue

I had an exercise to create two methods for simple queue class, first to delete last element and second to delete element at k position. Particularly I'm not asking for better implementation. Is it ...
ashur's user avatar
  • 423
4 votes
2 answers
6k views

Fixed size priority queue

I've tried implementing priority queue with fixed size in Java using TreeSet and overriding add() method: ...
robosoul's user avatar
  • 217
3 votes
1 answer
3k views

Javascript Queue for async functions

Based on the answer to my previous question on Stack Overflow, I put together the following Queue class. I realize there are already libraries out there to do this. However, I wanted to actually ...
Marcus Hughes's user avatar
6 votes
2 answers
18k views

Thread-safe message queue without mutex in C

I'm trying to write a message queue implementation so my threads can exchange data. To keep things simple, the queue is only responsible for sending pointers to memory. Only one thread may send ...
Lennart_96's user avatar
1 vote
1 answer
78 views

Action to transmit queued messages over a socket

I have this action and it works but looks rather clunky to me. Is there any way I could improve that? ...
J Fritsch's user avatar
  • 121
4 votes
1 answer
537 views

Javascript Queue Object

I created a Queue object when answering this question and I was wondering if it could do with some improvement. Here is the current code: ...
Naftali's user avatar
  • 1,089
6 votes
1 answer
204 views

Reducing memory footprint with queue of classes

I hope I've asked this in the right area. I'm writing a program that deals with enqueueing a class on STL queue in C++. Initially it queues initializations of the ...
James's user avatar
  • 61
2 votes
1 answer
249 views

What is this structure called?

I've been writing this data structure for a few days, and now I'm really curious about what it actually is, and to get some critique on my logic. A branch, based on this usage, exists when a ...
10001110101's user avatar
3 votes
1 answer
70 views

Extract equally from X queues to one queue with Y elements

I need to implement a system of queueing that extracts elements equally from x queues to one single queue with y positions. Let'...
tobia.zanarella's user avatar
2 votes
2 answers
9k views

Static class ThreadPool implementation

The following code is a self-implementation of the static class ThreadPool in C#, only the QueueUserWorkItem (the simpler method)...
rycle's user avatar
  • 145
2 votes
4 answers
6k views

Concurrent queue with pthread implementation

I'm writing a multi-threaded queue implemented with pthreads. Since I came up with the code based on several tutorials from Internet, I would like to make sure there are no logic errors in my code: <...
GuLearn's user avatar
  • 131
2 votes
2 answers
2k views

Optimize BFS weighted search in python

I have a weighted BFS search in python for networkx that I want to optimize: ...
fread2281's user avatar
  • 155
7 votes
1 answer
939 views

BFS for creating a queue without repetitions and with loops in the graph

I have a pipeline with loops of filters and one input filter. The rest are splitters, transform and output. I would like my code to go over the filters and push them into a queue (order is important)...
Gilad's user avatar
  • 5,311
7 votes
1 answer
438 views

STL-style deque class

I decided to write an STL-style class as an exercise. I followed a tutorial of sorts that I found online, but I also made some modifications. I'd like to hear any criticisms you folks might have. Be ...
piyo's user avatar
  • 171
5 votes
4 answers
8k views

Optimizing a thread safe Java NIO / Serialization / FIFO Queue

I've written a thread safe, persistent FIFO for Serializable items. The reason for reinventing the wheel is that we simply can't afford any third party dependencies ...
trialcodr's user avatar
6 votes
1 answer
1k views

A queue that switches from FIFO mode to priority mode

I implemented a queue capable of operating both in the FIFO mode and in the priority mode: when the priority mode is enabled, the elements are taken in order of decreasing priority; when the priority ...
enzom83's user avatar
  • 163
4 votes
2 answers
1k views

Binary tree max sum level - better design?

I have written some code for finding a level in a binary tree, having a maximum number of elements. I have a few questions: Is it a good design? I have used 2 queues but the total sum of elements ...
Manish's user avatar
  • 183
3 votes
1 answer
641 views

Message queues in Common Lisp

General advice for a change. This is an implementation of message queues that I'm going to use for some work on an actors model library. ...
Inaimathi's user avatar
  • 2,183
4 votes
2 answers
5k views

Robust logging solution to file on disk from multiple threads on serverside code

I have implemented a socket listener that runs on my Linux Ubuntu server accepting connections and then starting up a new thread to listen on those connections (classic socket listener approach). ...
dreza's user avatar
  • 6,417
3 votes
1 answer
22k views

Simple generic multithreaded queue

This is a simple thread safe queue that is used in a producer-consumer model. ...
Odys's user avatar
  • 133
4 votes
2 answers
9k views

Multithreaded item-processing queue

I have this Queue declared in my class: static private Queue<SignerDocument> QUEUE = new Queue<SignerDocument>(); ...
Guilherme de Jesus Santos's user avatar
8 votes
2 answers
1k views

Singly linked list queue class

I have a Queue class that is basically a single linked list. It has 2 remove methods. What would be the cleanest way to avoid duplication of the code? Only the ...
Kimmo's user avatar
  • 183
6 votes
2 answers
2k views

Custom JavaScript function queue

For fun, I made a function queue in JavaScript. I named it tinyq. You can add functions to it, and each function is passed the next function in the queue. You can also pass parameters to the ...
gen_Eric's user avatar
  • 730
3 votes
2 answers
12k views

Queue Implementation

First time I'm using stackexchange. I'm in 8th standard. I tried to implement Queue in Java. I wrote something like this> Right now I'm not able to test it because I don't have JVM in my machine. So I ...
Kiran's user avatar
  • 31
15 votes
5 answers
17k views

Java blocking queue

...
a3user's user avatar
  • 151
4 votes
1 answer
303 views

Trying to improve my jQuery animation queue

So I built a little baseball "scouting report" graphic that shows stats for players. As you page through the players, their images slide in and out of the graphic. I worked out a way to do this using ...
Kirkman14's user avatar
  • 205
7 votes
1 answer
729 views

Double-Ended Queue - Have I over-engineered it again?

I'm working on an implementation of the Double-Ended Queue as a Doubly-Linked List (for personal enrichment), and I was wondering if anyone minded taking a look at my Constructor/Destructor and Empty ...
wtfsven's user avatar
  • 221
4 votes
2 answers
2k views

FIFO queue for audio data

I have created a data structure to handle some audio data I am generating (simple sine wave right now). It had some errors in it due to some misunderstanding of my ancient C knowledge that has been ...
Jeffrey Drake's user avatar
2 votes
5 answers
2k views

Bounded blocking queue

Can someone please review this code for me? I have not implemented all the methods for simplicity. ...
p101's user avatar
  • 333
2 votes
1 answer
9k views

What value the rear and front counter of an Array implementation of Queue start with? -1 or 0 or 1?

Is there anything wrong with this implementation of Queue with array? I have started front = rear = -1. Some references tend to start front = 0 like this:enter link description here I think if ...
user avatar
8 votes
3 answers
6k views

fix ugly initialisation in while loop over queue

I have a loop structure, that I really don't like. It's the initialisation I find appalingly ugly. Is there a nicer way to do the following? ...
Martijn's user avatar
  • 585

1
5 6 7
8
9