Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
1
vote
1answer
79 views

C++ ring buffer using some C++ 17 and coming C++ 20 std::span [on hold]

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
1answer
63 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
1answer
49 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
1answer
66 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
2answers
1k 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
0answers
109 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
1answer
128 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
2answers
87 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
1answer
144 views

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

I've got this simple ring/circular buffer class: ...
7
votes
2answers
277 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
2answers
40 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
2answers
202 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
2answers
1k 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 ...
8
votes
2answers
5k 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
1answer
121 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
2answers
188 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
2answers
246 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
2answers
83 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
1answer
40 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
2answers
422 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
1answer
116 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
1answer
2k 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
2answers
224 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
2answers
7k views

Circular Queue Implementation Using Array in java

Here is my code of Array Implementation of Queue in java. ...
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, ...
1
vote
3answers
2k 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
0answers
525 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
1answer
309 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
1answer
988 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
1answer
5k views

Circular Linked List implementation in C++

I want to improve this code. ...
3
votes
2answers
322 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
4answers
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
1answer
1k 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
1answer
84 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
1answer
3k 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
1answer
665 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
2answers
591 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
2answers
520 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
1answer
711 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 ...
4
votes
1answer
3k 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
3answers
538 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 ...
9
votes
2answers
3k views

Circular Buffer C++ Implementation

I was asked this question in an interview, and didn't go through. I know, it needs some improvements, but probably I am missing something big? I would highly appreciate if someone can review it for me,...
6
votes
3answers
5k views

Elegant Circular Buffer

I would like to design an elegant yet efficient circular buffer of integers. I have designed a FIFO type circular buffer in C++(11)- starting with the class header (declaration) as follow: [...
9
votes
1answer
133 views

Rotate a given number of variables in-place

A very simple but useful algorithm: rotate the values of a given number of variables in-place to the left so that the first variable gets the value of the second, the second gets the value of the ...
7
votes
1answer
995 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 ...
0
votes
1answer
2k views

Deleting the head node of a circular linked list

Today I tackled this coding challenge: Given a circular linked list, implement a method to delete its head node. Return the list's new head node. I would appreciate any feedback. ...
19
votes
2answers
3k views

A Python wrap-around list

I want to gain experience creating data structures that look and feel like Python builtin types. As a first exercise, I've written a WraparoundList class meant to ...
4
votes
1answer
842 views

Circular doubly linked list with templates

I tried to write some code namely "Circular doubly linked list" and I would like to use templates to do this. This is the first time I use templates and throws some exceptions. I would like to know ...
2
votes
1answer
3k views

Implementing a queue using a circular buffer

I'm working on implementing a queue using a circular buffer problem. Any smarter ideas for better time complexity, any code bug or code style advice are highly appreciated. ...
3
votes
4answers
3k views

Circular array rotation Java

I have a solution to the HackerRank Circular Array Rotation challenge. It passes 7 test cases out of 15. The rest of them are getting timed out. I think it's because of the huge data set that has ...