Questions tagged [circular-list]
A circular list may be implemented using a fixed-size array (a ring buffer) or a linked list.
144
questions
5
votes
4
answers
875
views
Naming a method that gets the next enum value or starts from the beginning if the given value is the last
I'm struggling to find a proper name for a specific method (in code named NameOfExtension), and would also like some feedback about its implementation.
I am ...
2
votes
1
answer
109
views
C++ circular buffer that guarantees contiguous data
For interfacing with C-API that requires data in one contiguous block
I came up with the following, which seems to work nicely, but I wanted
to see if I didn't miss anything crucial. Drawback is of ...
1
vote
1
answer
61
views
next/prev function for a circular array
This is a next/prev function for use in a circular array. What do you think?
...
0
votes
0
answers
116
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 ...
2
votes
4
answers
268
views
Ring buffer for Arduino
Just wrote this small ring buffer system for an embedded device using C++98. Looking for cc, advice and bugs.
Please check it out!
https://github.com/Bambofy/EmbeddedRingBuffer
...
1
vote
3
answers
53
views
Embedded IoT: local data storage (Second Update)
I have made the review changes based on feedback I have got from here which was based on the feedback I got from this one. I am almost done and now looking for a final review with respect to any minor ...
4
votes
3
answers
60
views
Embedded IoT: local data storage (Updated)
I have made most of the review changes based on feedback I have got from here. Now I am back here for a second review to further better my code. Before posting the changes, somethings I haven't ...
6
votes
2
answers
512
views
Embedded IoT: local data storage when no network coverage
I am working on a part of an IoT project where I have been given a task to develop a mechanism to store data locally when there is no network coverage or if the network is down for some reason. Our ...
2
votes
1
answer
210
views
Circular Array - OOP
I have a solution for a circular array. How can I improve this?
...
2
votes
1
answer
1k
views
C++ ring buffer using some C++ 17 and coming C++ 20 std::span
When I heard about the new Linux I/O interface io_uring I searched about the ring buffer.
I then thought I may replace my safe queue which is base on C++ 11 ...
3
votes
1
answer
386
views
Ring buffer with random access
I had an application where I really wanted a double-ended queue that supports random access. Java's ArrayDeque would have been perfect, except that it doesn't ...
2
votes
1
answer
64
views
Circular Doubly Linked List with generators
I didn't find an implementation on CR of the circular doubly linked list, using generators. Hence, I tried it myself.
Description
The class Deck represents a ...
3
votes
1
answer
402
views
Producer consumer with threads and using boost ring buffer
I have two threads, one is the producer and other is consumer. My consumer is always late (due to some costly function call, simulated in below code using sleeps) so I have used ring buffer as I can ...
13
votes
2
answers
4k
views
Asynchronous Circular Buffer in C#
Preamble
I want to be able to test methods which communicate over a simple exclusively asynchronous two-way stream-like interface which may underneath use any of a number of communication methods (e....
4
votes
0
answers
334
views
Simple ring/circular buffer c++ class V4
As the title states, this is my 4th revision of this class.
Here is the previous post if needed.
I'm hoping someone experienced with things such as noexcept, ...
4
votes
1
answer
266
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 ...
2
votes
2
answers
111
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.
...
1
vote
1
answer
779
views
Simple ring/circular buffer C++ class [closed]
I've got this simple ring/circular buffer class:
...
7
votes
2
answers
553
views
Cyclic queue using an array
I tried to implement a cyclic Queue using an array, as a task from a coding interview.
Please comment about style, as well as any edge cases I may have missed.
...
2
votes
2
answers
60
views
Checking against a specific sequence in python
I'm trying to learn python and I'm modeling a simple dice game that a friend and I invented.
On any one turn of the game, you must roll a specific combination to stay in the game.
The particular ...
3
votes
2
answers
510
views
Circular Queue in C for an embedded project
I wrote a simple circular queue. (in order to store characters because of the fact, that I am using UART through the DMA and sometimes my printf's override each other)
I am looking for some review, ...
13
votes
2
answers
2k
views
Circular FIFO Buffer
I was bored the other day and got to wondering how I would implement a circular FIFO buffer in Rust. My goal was to create an implementation I could use on a bare metal microcontroller. This means no ...
13
votes
2
answers
27k
views
Ring Buffer Implementation in C++14
A ring buffer or circular buffer is a fixed sized queue that advances head and tail pointers in a modulo manner rather than moving the data. Ring buffers are often used in embedded computer design.
...
2
votes
1
answer
241
views
Find palindromes in circular rotated string
I'm trying to tackle a programming challenge to determine how many palindromes exist in a given string that is being rotated character by character. My solution works, but it's too slow, and I'm ...
0
votes
2
answers
533
views
Josephus Problem with cyclic iterator
Given the Josephus Problem.
Josephus Problem
N people (numbered 1 to N) are standing in a circle. Person 1 kills Person 2 with a sword and gives it to Person 3. Person 3 kills Person 4 and ...
3
votes
2
answers
564
views
Circular / Cyclic Buffer implementation
I am learning circular / cyclic buffer using this link. Here is the code that I have written so far:
...
2
votes
2
answers
93
views
Looping text with directional control
The code is an implementation of looping text (similar to a circular buffer - wraps around when it reaches the edge of the defined bounds) with directional control.
The code is functional and works ...
2
votes
1
answer
45
views
Looping text in Python with directional control
The code is an implementation of looping text (similar to a circular buffer - wraps around when it reaches the edge of the defined bounds) with directional control.
The code is functional and works ...
3
votes
2
answers
614
views
Customized lock-free RingBuffer
I have implemented my own lock-free ringbuffer for multiple producers multiple consumers using vector. Can you guys help me review to see if there are any problems and ways to improve?
Explanation:
...
4
votes
1
answer
213
views
JavaScript circular linked list compatriot game
I found this question in O'Reilly Data Structure and Algorithm in Javascript:
According to legend, the first-century Jewish historian Flavius
Josephus was about to be captured along with a band ...
7
votes
1
answer
3k
views
Multiple-producer, single-consumer lock-free circular queue
I'm working on a firmware on a bare-metal ARM single core processor (Cortex M4), with no RTOS. I need to add a multiple-producer, single-consumer, lockless fixed-size circular (ring) buffer to the ...
3
votes
2
answers
394
views
Find the sum of all digits that match the following digit in a circular list
The challenge
The captcha requires you to review a sequence of digits (your puzzle input) and find the sum of all digits that match the next digit in the list. The list is circular, so the digit ...
3
votes
2
answers
11k
views
Circular Queue Implementation Using Array in java
Here is my code of Array Implementation of Queue in java.
...
5
votes
2
answers
2k
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, ...
1
vote
3
answers
3k
views
Deque implemented using a circular array
I found a tutorial on implementing a deque using a circular array. I changed the implementation but I am not sure if it is correct or not.
So I have one question:
I wrote code that uses an ...
2
votes
0
answers
653
views
Really basic ring/circular buffer in Java
I needed a simple way to run tests on the last n bytes of data received from a socket, and a ring buffer seemed to be the most efficient way to handle it. This is a very basic buffer that stores ...
1
vote
1
answer
392
views
Split Circular linked list into two halves
I want to improve this code. I want to enter all values in linked list at a time like circular_linked_list<int> cll1(5, 10, 18, 25);
...
2
votes
1
answer
1k
views
Circular Doubly Linked List
After improving code from suggestions to my previous question.
I have implemented copy constructor, copy assignment, move constructor, move assignmnet. There is a suggestion for sentinal node but I ...
2
votes
1
answer
6k
views
Circular Linked List implementation in C++
I want to improve this code.
...
3
votes
2
answers
521
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 ...
10
votes
4
answers
2k
views
Advent of Code 2017, Day 1: Sum of digits matching the next digit (circular list)
I haven't used C++ for quite a while and wanted to practice a bit, so I decided to start simple and work through the Advent of Code 2017.
This is my solution to Part 1 of the Day 1 exercise "Inverse ...
1
vote
1
answer
2k
views
C Implementation of dynamic mem allocation using first-fit algo
I have implemented malloc and free in C based on first-fit algo and using a circular linked list for free blocks of memory. It seems to be working based on the basic test in the main function. I would ...
1
vote
1
answer
918
views
CodeChef Fusing Weapons in a circular list
I am currently trying to solve this problem on Codechef:
Before the start of each stage, N weapons appear on the screen in circular order. Each weapon has an integer associated with it, which ...
4
votes
1
answer
5k
views
Best way of implementing a circular buffer
I wanted to implement a circular buffer for learning purpose only.
My first option was to use a secondary status for rear and front pointers: (Like the ones I've seen in many websites)
...
1
vote
1
answer
1k
views
Implementation of IPC circular buffer
For a school assignment we had to implement IPC between two processes using File Maps with some specific requirements.
The relevant requirements are:
ComLib will send a null-terminated (C-style) ...
3
votes
2
answers
1k
views
Implementation of a Resizing Array Queue
Below is a problem from Sedgewick's Algorithms and my solution. Any thoughts or suggestions for improvement would be much appreciated.
Develop a class that implements the queue abstraction with
a ...
0
votes
2
answers
765
views
Binary protocol print utility in C++
Please review this protocol printer/decoder in C++.
I also attached a sample binary file to use to test.
Main program:
...
5
votes
1
answer
1k
views
Non blocking single producer/consumer queue with C++11 atomics
I've recently got interested in lockless programming, mainly lockless queues for job repartitions, so here I undertook a challenge of creating lockless queue for single producer and consumer.
This is ...
6
votes
2
answers
6k
views
C++ Circular buffer through Circular iterator
I saw some question on SO lately involving circular buffer, like a chain of descriptors for data transfer. All solutions involved lots of lines.
I wanted an implementation with as few lines as ...
4
votes
3
answers
737
views
Producer-Consumer with Peterson algorithm in java
Producer-consumer problem in Java with a circular buffer of N positions.
There is a single thread representing the producer that will produce consecutive integer elements
There is a dimensioned ...