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.
4
votes
1answer
229 views
Queue Implementation using a Linked List
For understanding the concepts, I've implemented the Queue data structures using a linked list. Is there anything to improve?
LinkList.java
...
5
votes
2answers
67 views
Espresso Queue simulation
I was asked to do a technical test with the following specification, but my solution was rejected and I was not selected for the available position (Junior to "normal" level, with 4 days of time to ...
2
votes
2answers
52 views
6
votes
3answers
579 views
STL Queue Implementation
I've implemented a simple C++ STL like queue. (I've tried to follow @LokiAstari stack implementation code fashion)
...
4
votes
4answers
223 views
LinkedList to be used in a stack or queue
This all works. Just wanted to make sure I didn't miss anything. Coming from C++ and working my way through Algorithms, 4th ed. Here is my LinkedList class:
...
1
vote
0answers
60 views
Optimizing implementation of Dijkstra
I am using a std::priority_queue to implement Dijkstra's algorithm:
...
3
votes
2answers
71 views
Displaying Items in a Circular Queue
I am dealing with the following problem. I have managed to solve it, however, I am not sure if my solution is efficient or the best possible solution. I am always willing to learn from my mistakes. ...
4
votes
0answers
111 views
Testing a lock-free job queue
I've created a lock-free job queue and with the tests I've written, which is also very fast.
That makes me doubt my benchmark procedure, so I'm hoping the collective knowledge will shed some light on ...
0
votes
1answer
71 views
Command line multipart or single file downloader
I am looking for a code review for this multipart or single file chunk downloader using threading and queues.
downloader.py
...
5
votes
4answers
101 views
Stack implementation using only one queue in C
We start with an empty queue. For the push operation we simply insert the value to be pushed into the queue.
The pop operation needs some manipulation. When we need to pop from the stack (simulated ...
5
votes
2answers
84 views
Revised Job Queue for Strategy Game
After posting my previous question about this Job Queue, I decided I wasn't actually very happy with it. I am embarrassed to admit that upon further testing it did not function properly in all ...
9
votes
2answers
393 views
Generic deque implementation
I implemented a generic deque data structure.
Please, review this implementation.
Deque.java:
...
5
votes
2answers
142 views
Queue over resizable array implementation
I study data structures on coursera's course, and there is an extra exercise to create a Queue data structure.
I created it:
...
3
votes
3answers
79 views
Threadsafe get method on queue that draws values from other queues?
I have a class that implements Queue and draws values from other queues which may still be referenced outwith it. I want my method to draw values from the contained queues, using synchronized locks on ...
5
votes
3answers
109 views
Job Queue for Strategy Game
I've posted a revised version of this here.
I posted about this basic problem a while ago, and I got the recommendation to move the code for managing the Jobs of my game to another class. I have ...
2
votes
4answers
120 views
Maximum of all subarrays of size k
Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.
Examples:
Input:
...
2
votes
2answers
56 views
Decide the start of the circular gas station path
Suppose there is a circle. There are n petrol pumps on that circle. You are given two sets of data.
The amount of petrol that petrol pump will give.
Distance from that petrol pump to the ...
5
votes
2answers
157 views
Find max-number div by three to be formed by array elements
Given an array of non-negative integers, find the largest multiple of 3 that can be formed from array elements.
For example, if the input array is {8, 1, 9}, the output should be "9 8 1", and ...
4
votes
2answers
123 views
Implement queue using linkedlist
Implement queue using linkedlist. Looking for code review, optimizations and best practices.
...
3
votes
2answers
70 views
Class that implements a queue using two stacks
I am looking for a review of my code that implements a MyQueue class which implements a queue using two stacks.
...
4
votes
1answer
325 views
Queued Employees
The following example shows how to implement a queue in an employee structure. I am looking for a review of the implementation:
...
0
votes
0answers
74 views
WebApi synchronize database (EF 6) access
I'm working on an ASP.Net MVC 5 /WebApi 2 project. I'm using EF 6 code first for my database access.
I've a WebApi action method in which I've to update some data in my database based on the request. ...
3
votes
0answers
64 views
Twitter Streaming Client - Round#2
This is round #2. The initial code review is: Twitter Streaming API Client: Identifying the top trending hashtags for a specific term.
For a list of changes since the last review please see: ...
3
votes
0answers
117 views
Concurrent queue
I recently wrote a concurrent, mutex-less (but not lockfree) queue and wanted to know if it is actually correct, and if there are any particular improvements I could make:
...
0
votes
2answers
106 views
Stack implementation using a queue
I've implemented a stack using a queue.
Time complexity:
\$O(n)\$ - push(), where n is the number of elements in the queue
\$O(1)\$ - ...
4
votes
5answers
769 views
Circular queue implementation
Implemented simple thread safe circular queue. Looking for code review, optimizations and best practices.
...
3
votes
1answer
114 views
Lock-free queue with doubly linked list correctness
I need a lock-free queue which is implemented by doubly linked list.
Is my code correct? Are there any errors? Are there any improvements to be made?
linkedlist.h
...
3
votes
2answers
113 views
Thread-safe queue
I need a thread-safe C++ queue. This is what I have in my project, which is mostly based on code I've found on Stack Overflow. How good is it? Can you make it better? Can you suggest better ...
4
votes
2answers
178 views
Worker AI and Job Queue Management for Simulation Game
So I've been working on AI for a Tower Building simulation game for quite a few days, and I think the code would really benefit from review. I'm a hobbyist programmer, but I really care about doing ...
5
votes
1answer
134 views
Managing People in a SimCity Clone
So I am working through a few different game ideas as I learn programming, and I could definitely use some feedback on my latest project. This is a simple SimCity clone. So far I have created a City ...
2
votes
1answer
73 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 ...
7
votes
1answer
294 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()
...
3
votes
1answer
187 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 ...
10
votes
3answers
571 views
Tail implementation in C
Write the program tail, which prints the last n lines of its input. By default, n is 10, ...
3
votes
0answers
66 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 ...
10
votes
1answer
3k 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 ...
5
votes
1answer
150 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. ...
7
votes
1answer
810 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 ...
10
votes
2answers
3k 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
...
3
votes
1answer
156 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 ...
7
votes
2answers
2k 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.
...
2
votes
3answers
2k 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 ...
5
votes
1answer
122 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 ...
5
votes
2answers
458 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 ...
2
votes
4answers
358 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 ...
1
vote
1answer
59 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 ...
1
vote
1answer
108 views
4
votes
2answers
486 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 ...
1
vote
1answer
443 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 ...
2
votes
2answers
516 views
Fixed size priority queue
I've tried implementing priority queue with fixed size in Java using TreeSet and overriding add() method:
...