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
4
votes
1answer
460 views

Circular doubly linked list in JavaScript

I've been studying data structures and have taken a stab at implementing a doubly LL in JavaScript. Please review and advise on any additional improvements and optimizations. I'm more interested in ...
4
votes
2answers
2k views

Circular buffer implementation using linked list

I'm a beginner with C. The below is the implementation of circular buffer using linked list. Please review my code and suggest any improvements to make it efficient or to improve in coding style. <...
4
votes
1answer
107 views

Rotating list in python

This is a list class which allows users to "turn" the list while keeping track of the current position. For efficiency, the list is not actually rotated on each rotation, but instead an offset keeps ...
5
votes
2answers
2k views

constant sized circular (ring) buffer

I've implemented constant sized circular buffer. It provides push and pop operations, along with modern emplace. It is also optimized for destruction of trivially destructible types. I didn't include ...
6
votes
5answers
3k views

A buffer that holds and provides the latest n items

I have developed the following code to hold n latest items it has received, and when asked for provide these n latest items. The interface is: ...
9
votes
3answers
29k 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
3answers
9k 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 ...
2
votes
2answers
8k views

Circular Singly Linked List using Java

Please review my implementation of Circular Singly Linked List ...
2
votes
3answers
13k 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
0answers
476 views

Concurrent resizable ring buffer

I'm trying to find the fastest way to enqueue and dequeue items concurrently in Go. There are some restrictions: it needs to be unbounded Memory allocation should be low Multiple producers (Single ...
10
votes
2answers
1k views

Circular Buffer in C - Follow Up

This is a follow up to this post I uploaded a few days back on my alternative account about a circular buffer in C. I'm confident that I fixed most of the warnings and even added an iterator. ...
8
votes
3answers
357 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. ...
11
votes
5answers
586 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 ...
18
votes
1answer
1k views

C and CUDA: circular buffer implementation

I have a programme which uses many circular buffers in an identical fashion on a CPU and GPU (C and C/C++ CUDA). I essentially require many queues, however, due to this being run on a GPU, I have ...
6
votes
1answer
153 views

Rate limiting function calls

I wanted to write a function that when applied to another would rate limit it, but permit all calls to eventually make it through. Comments and criticism welcome. ...
4
votes
3answers
557 views

Implementing CircularQueue using Linked List in C++

I'm currently doing a project, requiring me to implement a CircularQueue data structure in C++: ...
2
votes
1answer
551 views

Doubly circular linked list implementation

I made this C++ doubly circular linked list implementation and it seems to work right, handle everything well, and not have any errors. However, I've been working with it for a while and would like ...
2
votes
1answer
736 views

Circular array list in C

Now I have this circular array-based list in C. Circularity allows pushing/popping to the both ends of the list in constant amortized time. Inserting/removing at random locations runs in linear time, ...
7
votes
1answer
799 views

Stack using an array

I designed a simple drop-out stack a while back. Basically, I just want to get a few opinions on whether or not this is a good implementation and whether I am understanding the concept of a drop-out ...
4
votes
3answers
227 views

Finding the tallest and find the index number of the next taller guy in a circular queue

Input given is: Each test case contains two lines. The first line contains a single integer N (1 ≤ N ≤ 105), the number of persons playing the game. The second line contains N integers i(height) (1 ...
2
votes
3answers
136 views

ADT Stack with a doubly circular linked list

I have managed to implement an ADTStack with a circular doubly linked list. I would like to know whether there are things I could have done better or, I should ...
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 ...
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 ...
3
votes
2answers
608 views

Linear Probing in Python

About to get back into coding, so I implemented linear probing in Python. How did I do? Anything unnecessary? Am I using "global" right? I originally wanted to use an array with a fixed length, but ...
1
vote
0answers
123 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 ...
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
0answers
131 views

Ring Buffer using templates/macros

I just wrote my first Nim module and was hoping someone with some experience with Nim or similar languages could take a look. In particular I was hoping someone could speak if the use of ...
5
votes
5answers
42k views

Shift elements left by n indices in a list

For the following question, the function • should mutate the original list • should NOT create any new lists • should NOT return anything Functions that do not create new lists are ...
5
votes
4answers
2k views

Survivor programming challenge

I am working on a survivor problem: Complete Question Text: Take a second to imagine that you are in a room with 100 chairs arranged in a circle. These chairs are numbered sequentially from One ...
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: ...
7
votes
1answer
25k views

Left Shifting an array of ints

The problem I am referring to is here So basically it's about shifting an array of ints 1 position to the left and relocating the lost first int in the start of ...
3
votes
1answer
976 views

Bootstrap show many move one carousel modification

I've been steadily improving a show many move one carousel sample that I found a few weeks ago. I want to post my improvements for others to use but don't want to spread bad code. I'm not an expert in ...
3
votes
1answer
6k views

Efficient Ring Buffer (FIFO)

I need to implement a Ring Buffer/FIFO for data coming from a TCP socket. It must support the following operations: Append a the recv()'ed chunk of bytes. Allow me to peek at the beginning of the ...
8
votes
1answer
464 views

Ring datatype in Python

I wanted to write something that would be useful for the indices of a grid where if one walked off the edge of the grid they would re enter on the opposite side. This could in theory help with ...
5
votes
0answers
2k views

Disruptor pattern in a lock-free producer-consumer queue

I'm implementing a quick-and-dirty lock-free MPMC queue in C++, based on the v3 Disruptor algorithm. The implementation is pretty simple: Data to be shared between threads is stored in a ring buffer. ...
5
votes
1answer
4k views

Lock-free ringbuffer with multiple readers in C++11

Basic Info I needed a lock-free ringbuffer with multiple readers (but one writer). However, I did not want the writer to check all readers every time in order to prevent an overrun. Thus, I decided ...
3
votes
1answer
464 views

Searching for a substring in a ring queue

I am implementing a function which searches through a ring queue for a given substring. The function returns true if the substring is found, otherwise false. There is a cell containing null between ...
3
votes
1answer
2k views

Circular Queue using Linked List

I want to create a circular queue using a linked list. I also want to create many instances of that data structure (queue) without repeating the code. This is what I came up with: ...
4
votes
1answer
7k views

Circular linked list in C

Let me know if it seems right to you and if anything can be optimized. My concern is that I'm unsure if circular linked lists are supposed to have a tail. I've implemented it just using a head. Is ...
3
votes
1answer
871 views

Circular queue implementation using two regions

Inspired by the "bip buffer", I coded a fixed-size circular queue that uses two regions (two pairs of begin/end pointers) to account for the wrap-around. The main goal of this design was to simplify ...
1
vote
1answer
602 views

Circular buffer offsets and sorted set of offsets sorted on their index

Consider the following C++03 code: ...
5
votes
2answers
3k views

Read file line-by-line with circular buffer

This isn't too complicated but I usually code in C++ instead of C. Doing memory management and IO in C always makes me feel like I'm doing everything wrong and making a mess. This is a small sample ...
2
votes
1answer
3k views

Form a loop with previous and next

I have a class Edge which looks something like this: class Edge { Edge previous; Edge Next; } I have edges in an <...
1
vote
1answer
509 views

Creating an insert at front function for a circular doubly linked list

I have only been working with C for a couple of months and I think I have a pretty good function to insert a node in the front of the circular doubly linked list. I have tested in adding several ...
6
votes
2answers
4k views

Queue implementation without using built-in data structures

In an effort to brush up my algorithms and data structure skills I have a done a queue implementation without using built in data structures, i.e. using only arrays. Any comments on this code ...
5
votes
3answers
804 views

Cyclic iterator in both directions

I am trying to make a cyclic iterator that works backwards and forwards. getNext() gets the next array item, getPrevious() gets ...
3
votes
1answer
1k views

Circular Buffer implementation in Ruby

Does the implementation look correct? Did I miss something major/minor? ...
5
votes
1answer
334 views

Lockless, blocking, non synchronized multiple producers and consumers ring buffer

My program is structured like this: there are M producer threads, each of which computes a section of an object O with index <...
1
vote
1answer
5k views

Doubly circular linked list implementation with successive update in O(1)

For the queries mentioned in link in 3 parts, the first two parts have been addressed, as mentioned below: Part I (6 points) list/DList.java contains a skeleton of a doubly-linked list class. Fill ...
2
votes
3answers
795 views

CodeChef Matrix Rotation

I am new to C# and have tried to solve a problem statement from CodeChef: Problem statement You are given an array A of N integers. You are to fulfill M queries. Each query has one of the ...