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
2 votes
0 answers
26 views

Ringbuffer over a const generic Array in Rust

I implemented this generic ringbuffer over a const generic array with the usage of the MaybeUninit type. Is there something which is maybe unsound (having the lines ...
Lockna's user avatar
  • 121
3 votes
2 answers
80 views

Enhancing a non-multithreaded Circular buffer

Looking to get some feedback on a simple non-multithreaded circular buffer. Ideally, I'd want to have a logic to prevent the data from getting overwritten but couldn't find a reasonable way. For ...
xyf's user avatar
  • 508
1 vote
2 answers
103 views

Circular list vs. doubly-linked list: which is faster?

In this post, I will compare performance of a circular list and a conventional list with head/tail -references: ...
coderodde's user avatar
  • 27k
6 votes
2 answers
1k views

A not so simple C++20 circular queue

This container reduces the number of memory allocations on queue-type operations (push + pop) compared to std::deque. Basic performance tests indicates a performance similar to std::deque where main ...
Gerard Torrent's user avatar
2 votes
1 answer
178 views

Simple C++ circular queue

I wrote a simple C++20 circular queue. https://github.com/torrentg/cqueue Here is cqueue.hpp ...
Gerard Torrent's user avatar
2 votes
1 answer
81 views

Ring buffer for non-trivial types

I tried to explain in detail everything there should be of concern regarding this particular implementation, and non-code body turned out quite long, scroll down if you just want to read the ...
yotsugi's user avatar
  • 21
6 votes
2 answers
762 views

std::array based push-only circular buffer

Minimal implementation of a circular buffer based on std::array, where elements can only be pushed and iterated. I'm interested on potential failures and very trivial optimizations, as I'd like to ...
Sdra's user avatar
  • 163
5 votes
4 answers
1k 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 ...
c-chavez's user avatar
  • 153
2 votes
1 answer
1k 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 ...
Jahn's user avatar
  • 23
1 vote
1 answer
176 views

next/prev function for a circular array

This is a next/prev function for use in a circular array. What do you think? ...
user1095108's user avatar
  • 1,414
3 votes
4 answers
833 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 ...
Richard Bamford's user avatar
1 vote
3 answers
61 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 ...
Vinay Divakar's user avatar
4 votes
3 answers
68 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 ...
Vinay Divakar's user avatar
6 votes
2 answers
531 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 ...
Vinay Divakar's user avatar
2 votes
1 answer
251 views

Circular Array - OOP

I have a solution for a circular array. How can I improve this? ...
Neslihan Bozer's user avatar
2 votes
2 answers
2k 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 ...
dev65's user avatar
  • 303
3 votes
1 answer
574 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 ...
Harry Braviner's user avatar
2 votes
1 answer
88 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 ...
dfhwze's user avatar
  • 13.9k
3 votes
1 answer
732 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 ...
noman pouigt's user avatar
14 votes
2 answers
5k 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....
VisualMelon's user avatar
  • 7,421
3 votes
4 answers
253 views

The last standing gunman in a circle

I don't know why in most of the interviews, interviewers are asking this question commonly. The question is: There are n number of persons standing in a circle. ...
Krishnakumar Subramanian's user avatar
4 votes
0 answers
412 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, ...
Hex's user avatar
  • 425
4 votes
1 answer
343 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 ...
Hex's user avatar
  • 425
2 votes
2 answers
133 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. ...
Hex's user avatar
  • 425
1 vote
1 answer
1k views

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

I've got this simple ring/circular buffer class: ...
Hex's user avatar
  • 425
7 votes
2 answers
690 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. ...
Gilad's user avatar
  • 5,321
2 votes
2 answers
68 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 ...
mAndroid's user avatar
  • 165
3 votes
2 answers
611 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, ...
Oliver Al-Hassani's user avatar
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 ...
RubberDuck's user avatar
  • 30.8k
16 votes
2 answers
44k 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. ...
davidbear's user avatar
  • 577
2 votes
1 answer
282 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 ...
AnonymousSB's user avatar
0 votes
2 answers
588 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 ...
MAttti's user avatar
  • 35
3 votes
2 answers
752 views

Circular / Cyclic Buffer implementation

I am learning circular / cyclic buffer using this link. Here is the code that I have written so far: ...
skr's user avatar
  • 539
2 votes
2 answers
102 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 ...
Yaseen Ssenyonjo's user avatar
2 votes
1 answer
57 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 ...
Yaseen Ssenyonjo's user avatar
3 votes
2 answers
663 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: ...
interceptwind's user avatar
4 votes
1 answer
260 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 ...
Kenneth Akpo's user avatar
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 ...
vgru's user avatar
  • 1,388
3 votes
2 answers
444 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 ...
jrtapsell's user avatar
  • 505
2 votes
3 answers
1k views

Codility cyclic rotation solution in PHP

Problem statement A zero-indexed array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is also ...
riser101's user avatar
  • 143
3 votes
2 answers
12k views

Circular Queue Implementation Using Array in java

Here is my code of Array Implementation of Queue in java. ...
Sagar Devkota's user avatar
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, ...
Anonymous3.1415's user avatar
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 ...
beehuang's user avatar
  • 111
2 votes
0 answers
751 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 ...
ndm13's user avatar
  • 718
1 vote
1 answer
441 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); ...
coder's user avatar
  • 2,449
3 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 ...
coder's user avatar
  • 2,449
2 votes
1 answer
6k views

Circular Linked List implementation in C++

I want to improve this code. ...
coder's user avatar
  • 2,449
3 votes
2 answers
634 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 ...
user avatar
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 ...
mkrieger1's user avatar
  • 1,694
1 vote
1 answer
3k 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 ...
Vikas Yadav's user avatar