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.

learn more… | top users | synonyms

4
votes
3answers
33 views

Lock-free SPMC queue

Here is my lock-free queue implementation for single producer with some preallocated memory. T is a simple type with no need for move operations. I don't use ...
2
votes
0answers
21 views

Immutable queue implementation in Scala

I created a queue in which we can perform Enqueue, Dequeue and Traversing in Scala. ...
5
votes
1answer
33 views

Converting Binary Tree to LinkedLists

The problem statement is : Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth (e.g., if you have a tree with depth D, you'll have D linked ...
10
votes
3answers
801 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" ...
1
vote
0answers
79 views

Are there pitfalls to this solution to read messages from a queue in parallel?

I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed. Situation We have one message queue. We would like ...
3
votes
0answers
44 views

Updatable priority queue

This is an updatable priority queue. In contains an index (implemented as std::unordered_map) which maps a value to its position in the queue itself. The queue is ...
6
votes
1answer
42 views

Queue implementation in Java

This is my Queue implementation in Java. Would appreciate a review of the code. ...
6
votes
1answer
129 views

Priorizatable command queue

This code consistently executes commands with a given priority. How can I to improve it? ...
4
votes
3answers
99 views

Implementing CircularQueue using Linked List in C++

I'm currently doing a project, requiring me to implement a CircularQueue data structure in C++: ...
4
votes
2answers
679 views

Simple FIFO and LIFO ferry simulator

I am trying to make a ferry simulator with one ferry that works like a stack and another like a queue. I have a working class for stacks and queues with pop/push; I am trying to figure out how to ...
3
votes
2answers
43 views

LinkedList Queue implementation

I'm working on a project which simulates (very simple/watered down) a network. The basis of this is to learn how to implement a Queue. I understand there are many ...
2
votes
1answer
126 views

MPMC lock-free queue

I'm pretty new to the world of lock-free programming and would love some feedback on this code. I have been testing the queue with multiple producers and consumers, and with no unexpected output ...
-1
votes
2answers
103 views

Stack using two queues

I have implemented the Stack using two Queues q1 and q2 respectively as shown below in the code. I would like to get you reviews on whether it's an efficient way of implementing it or now. For Pop ...
5
votes
2answers
170 views

Queue implementation using arrays

Please review the code: ...
4
votes
3answers
111 views

Lock-free MultiConsumer/MultiProducer queue

I've written a simple lock-free multi-consumer/-producer FIFO queue. It's supposed to work like this: At any time many consumers may read from it At any time multiple producers can write to it, ...
3
votes
2answers
62 views

Lockless SCSP queue

I'm looking for a code review on a class that I've written. It was my first attempt at lockless programming and I'd love any feedback I can get. ...
4
votes
2answers
190 views

Thread-safe lock free FIFO queue

A few years ago there was a need to add a FIFO queue between 2 threads into my project. At that time I've got some interesting idea how to do that without any atomics and locks. (There was a ...
-2
votes
2answers
113 views

Simple Implementation of a BlockingQueue

An implementation of BlockingQueue ...
8
votes
5answers
339 views

RingQueue implementation using std::array

I've recently finished implementing a ring queue based on std::array in C++11. I tried to write the code as if I were going to submit it to the C++ Standard ...
-3
votes
1answer
86 views

Verify FIFO dequeue algorithm

I have a FIFO queue of packets, which maintains: Push index Pop index Count I would like to assert my dequeuing algorithm: ...
5
votes
4answers
449 views

Implementation of C linked list (Queue) of C strings on mega AVR

I have been working on a mechanism to queue up strings coming into a system via a USART and have implemented it as a singly linked list. I have done my best to profile the code and its memory usage at ...
4
votes
1answer
61 views

Serializable Queue header only library

I was hoping someone could check the library I 'm working on to see if they could give any suggestions. My biggest issue right now is getting tuple to work with more than just the basic types and I ...
2
votes
1answer
156 views

Priority blocking queue implementation

This is a follow on question from one I asked a few days ago here: Single process blocking queue Using the comments I determined that there probably isn't a pre-built solution for this and so I have ...
7
votes
1answer
725 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 ...
3
votes
1answer
184 views

Making a copy constructor more flexible for ADT queue

I have constructed a copy constructor for an ADT queue. The copy constructor works fine. I would want to improve my code, but I don't really know how to shorten it to make it more flexible. ...
6
votes
1answer
129 views

Lock-free, multiple consumer, multiple producer queue

I'm implementing a lock-free, multiple consumer, multiple producer FIFO queue/pipe as an exercise in thinking about atomicity in operations. My main concern is correctness of operation, my second ...
4
votes
1answer
469 views

Lockless multi user, multi consumer FIFO queue using C++11

One of the features that is missing from C++11 are lockless queues. Therefore I have decided to write one myself. A few remarks: I know the code isn't technically lockless. However the lock is only ...
5
votes
1answer
77 views

MailQueue - follow up

Follow up of this question. Things altered: Put logging (debug level) for creating and starting thread. A separate thread for starting the different threads. Locking object and synchronise for ...
7
votes
2answers
157 views

MailQueue implementation with auto start - stop

Previous question was a little portion of the mailQueue. I finished the MailQueue, which has the ability to start and stop ...
6
votes
2answers
123 views

Templated queue implementation

I wrote an implementation for a simple queue in C++ (for practice, since there's an stl queue). I've been trying to focus on memory management and the rule of three. Any suggestions/improvements? ...
2
votes
2answers
206 views

ConcurrentLinkedQueue to unmodifiable list

I have a ConcurrentLinkedQueue where I put some mails in. Now I have a visual page where I want to see what's in the Queue, but ...
3
votes
2answers
119 views

Shutdown method in queue implementations

I am trying to implement a shutdown method in queue implementation. I took the code from BlockingQueue source from Java and trying to check the shutdown method. Will the following code be thread safe ...
2
votes
1answer
627 views

Priority Queue Linked List Implementation

I am new to Python and wanted to make sure my code answers the question for my assignment due. My Task: A priority queue is a queue in which each item is assigned a priority and items with a ...
2
votes
1answer
220 views

Fixed size double-ended queue

I require hundreds of equal, small sized buffers in my current project. The bulk of the computation in the program operates on data stored directly in those containers, so high performance is ...
2
votes
0answers
33 views

Functional, Loaner-Like Pattern For Consuming SQS Queues, Deleting Queue Items On Success

My program fetches input from a RabbitMQ or Amazaon SQS-like queue. There is not always input available in the queue. If a message is available, it triggers work. If that work is successful, ...
1
vote
0answers
368 views

Simple Priority Queue

I am trying to implement A* search on a grid in MATLAB. I am currently using a priority queue class I found here, but it's a bit slow. I tried to write this simple priority queue class in MATLAB: ...
2
votes
1answer
82 views

Asynchronously load and unload a queue

This code is supposed to asynchronously load a queue from a generating function. ...
2
votes
1answer
1k views

Array-based FIFO queue in C

I have this "generic" implementation of an array-based FIFO-queue. As I have written very little code in C, I don't have an idea what to ask, so feel free to tell anything that comes to mind. ...
3
votes
1answer
3k views

Printing a tree level by level

I have written a program to print a binary tree level by level on different lines, like the tree would actually look if drawn on paper. I have done a BFS traversal and then I proceed to print the ...
3
votes
1answer
275 views

Sum of left and right nodes (individually) in a Binary Search Tree

I have written a program which calculates the sum of all the left nodes and the sum of right nodes in a Binary search tree. I have used BFS to traverse the tree. The code is as follows: ...
0
votes
1answer
129 views

Queue like system to check existence of email

I have a table in my database containing email and email_state amongst other values. Email is the email of the contact, and ...
1
vote
1answer
46 views

Reload pickled objects into dict - assigned to variable name from file name

I'm doing a bunch of work with echonest audio objects (as returned by the echonest API) in the Python CLI and rather than having to recreate them each time, they can be saved. This bit of code ...
3
votes
2answers
498 views

Immutable Queue in Java using an Immutable Stack

I am new to this Immutability concept and I have some coding experience in JAVA. Recently as a part of internship program, they gave me a 5-day task, which was to implement Immutable Queue. After some ...
2
votes
1answer
474 views

Circular Queue using Linked List

I want to create a circular queue using a linked list. I also want to create many instances of that data structure (queue) without repeating the code. This is what I came up with: ...
2
votes
1answer
656 views

Binomial heap in Java

I have this implementation of a binomial heap providing insert, decrease-key and extract in logarithmic time. MinPriorityQueue.java: ...
3
votes
1answer
246 views

Circular queue implementation using two regions

Inspired by the "bip buffer", I coded a fixed-size circular queue that uses two regions (two pairs of begin/end pointers) to account for the wrap-around. The main goal of this design was to simplify ...
7
votes
5answers
957 views

Simple server to manipulate priority queues

In a few months I'll work on a C++ project that could span a year or two. I've a strong C background and for the usual reasons I always chose C over C++ (please forgive me). To extend my capabilities ...
3
votes
1answer
943 views

Queue with std::vector

How can I improve this code? ...
3
votes
1answer
260 views

Implementing a simple queue in C

I am learning C and I have some trouble with pointers. I decided to create a queue to practice a bit. The program works as intended, however I want to know some good practices and suggestions. Here ...
4
votes
1answer
15k views

Shortest path Dijkstra's algorithm

I'm trying to implement Dijkstra's algorithm to find the shortest path from a starting node to the last node of a 250px by 200px raw image file (e.g. starting node = [0][0], ending node = [250][200]). ...