Questions tagged [circular-list]

A circular list may be implemented using a fixed-size array (a ring buffer) or a linked list.

Filter by
Sorted by
Tagged with
29
votes
1answer
6k views

100 gunmen in a circle kill next person

I am very happy because I solved this problem with very little code: ...
18
votes
3answers
20k views

Index into array as if it is circular

The problem: Treat an array as if it is circular; out-of-bounds indices "wrap around" the array to become in-bounds. Current solution: ...
17
votes
2answers
2k views

O(1) lock free container

This is a lock-free Container class. By Container I mean it will hold objects for iteration at a later time. To achieve \$O(1)\$ ...
11
votes
5answers
589 views

FiniteArrayQueue type with interface and unit tests

Doing some exercises on basic data structures, I learned about queues, and decided to roll my own to better understand how a basic queue can function. As the name indicates, this Queue is made from a ...
9
votes
3answers
30k views

Circular Buffer C++11 Implementation

Here's the implementation of a common data structure I use at work, mainly for logging purposes. I tried to make it C++11-compliant, but even if this standard has been around for a few years, it is ...
10
votes
2answers
10k views

Circular Buffer Implementation

I'm implementing a "live analytics" feature and I need to always keep track of the last N items that were added to a collection so I figured I'd make a circular buffer since I couldn't find one. I ...
7
votes
1answer
984 views

Implementation of fixed size queue using a ring (cyclic) buffer

I found myself in need of a fixed size queue and decided to implement one using a ring (cyclic) buffer. I have tried my best to match the API of std::queue with ...
11
votes
3answers
9k views

Doubly-Linked Circular Linked List

I'm a C++ programmer learning Java in preparation for an OOP class this fall. That being said, Java is fairly new to me so I'd love to hear feedback on how to improve this code. A few notes: Code ...
4
votes
3answers
8k views

Circular Singly Linked List using Java

Please review my implementation of a Circular Singly Linked List. ...
2
votes
1answer
4k views

Circular Linked List implementation in C++

I want to improve this code. ...
1
vote
1answer
21k views

Doubly circular link list implementation

I am supposed to be creating a doubly circular linked list, but I am now have problems creating the actual linked list. Is there a problem with the classes? Also, for the assignment, the list is ...
8
votes
3answers
363 views

Circular Buffer

For my current project I need a circular buffer, which is able to do the following things: Push something to it (to the head). Pop something from it (from the tail). I don't need the popped data. ...
6
votes
2answers
2k views

Ring buffer for audio processing

Below is my source code for the implementation of a Ring/Circular buffer for use in audio processing. I have been using this implementation for several months now but I have some doubts about the ...
5
votes
2answers
1k views

Compare two lists to see if one is a rotation of the other

Going through a list of common interview question, this was the next one. Any suggestions on performance and improvement? What would be a better implementation of this? Also correct me if I'm wrong, ...
4
votes
1answer
120 views

Simple ring/circular buffer c++ class V3

The Original Post (v2) As stated in the previous post, i'm looking for feedback on the updated version of the code posted. A few things specifically I'm looking for feedback on, are: I switched to ...
3
votes
1answer
3k views

Array slice type in Java

Edit See the next iteration at Array slice type in Java - follow-up. I have this "slice" type for managing array subranges. It is kind of the same thing as Pythons slice notation, yet I did not add ...
3
votes
2answers
314 views

SPOJ Class Leader using circular linked list

I have solved a spoj question CLASS LEADER. For each test case there are n students and a paper will be given to student m and now the game starts, the student m will pass the paper by o positions ...
3
votes
2answers
1k views

Ring buffer for audio processing (follow up)

This question is a follow up in regards to the comments suggested in a previous post regarding a Ringbuffer implementation in C++ for audio processing. Ring buffer ...
2
votes
3answers
14k views

“Prev” / “Next” buttons for a circular list

I have an array of strings and on click of the "NEXT" button it displays the next array item in a <p> tag while on click of the "PREV" button it displays the ...
2
votes
2answers
84 views

Simple ring/circular buffer c++ class V2

The Original Post (v1) I'm looking for feedback on the updated version of the code posted at the link above. ...
2
votes
3answers
1k views

“Fun with Rotation” - Codechef September Challenge

Can you please help me in reducing the complexity of the below code? The problem statement can be found here. You are given an array A of N integers. You are to fulfill M queries. Each query has ...
1
vote
1answer
137 views

Simple ring/circular buffer C++ class [closed]

I've got this simple ring/circular buffer class: ...
1
vote
0answers
126 views

Array slice type in Java - follow-up

See the previous iteration. I have essentially fixed most of the issues mentioned by maaartinus. However, I left the size field as it is. Namely, if the user wants ...