The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
3
votes
1answer
473 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 ...
10
votes
4answers
5k views

Circular Bounded Queue using C#

As an exercise, I have implemented a circular bounded queue using arrays as the base data structure. I'd appreciate it if someone can review it for me. ...
2
votes
3answers
806 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 ...
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 ...
5
votes
2answers
18k views

Producing every string of a given length using some range of characters

Ever since I was a kid I wanted to understand how brute force programs work. I have not been able to make sense of any of the examples throughout the internet, so it became a personal challenge to ...
3
votes
1answer
887 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
625 views

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

Consider the following C++03 code: ...
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 ...
3
votes
2answers
4k views

Displaying items in a circular queue

I am dealing with the following problem: Write a method for the Queue class in the queue.java program (Listing 4.4) that displays the contents of the queue. ...
1
vote
1answer
514 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 ...
2
votes
1answer
412 views

Inky pinky ponky game / Josephus problem

I have written below code for the famous Josephus problem, or inky pinky ponky game, or many other names. Does this looks good or is there any loophole if anyone can highlight. I shall be looking ...
5
votes
2answers
547 views

Circular linked list of integers

I'm looking for a review paying special attention as to whether the code can be optimized in the form of number of variables used, especially for the delete() ...
5
votes
1answer
3k views

Single consumer and single producer lock-free circular buffer

I'm pretty new to multithreading. The code below is a simple implementation of a single consumer/single producer circular buffer that does not use any locking, that I wrote for fun. The question is,...
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 ...
7
votes
2answers
5k views

Circular buffer implementation for buffering TCP socket messages

I have written my own for practice and also some tweaks for my specific requirement. There is an insert which can copy a range (well array copy really) which I am hoping is more efficient than ...
3
votes
1answer
542 views

Circular Buffer on a typed Float32Array

I am sure there are better ways to do things but this is part of my first JavaScript project and I'm slowly getting accustomed with how things work in JavaScript. This is also why I ask for a code ...
5
votes
5answers
21k views

Circular queue implementation

I've implemented a simple thread-safe circular queue. I'm looking for code review, optimizations and best practices. ...
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 ...
4
votes
3answers
29k views
6
votes
1answer
4k views

Multi threaded circular buffer

I've written a circular buffer with multithreaded write and single read ability: ...
7
votes
2answers
1k views

Counting number of nodes between two nodes

This code counts the number of nodes between any given two nodes in a circular linked list. Any feedback is appreciated: ...
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 ...
5
votes
1answer
341 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 <...
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
4k 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 <...
2
votes
2answers
3k views

Lock-Free Ring Implementation

I am wondering if someone can take a look at my lock-free, circular ring implementation which I use to implement a background logger. The CircularRing pre-...
5
votes
3answers
843 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? ...
3
votes
3answers
858 views

Unbounded, High-performance(?), Generic, Thread-Safe(?), BatchedCircularQueue

This is a data structure I wrote: It is an circular first-in-first-out queue (a ringbuffer); It has batched removal/popping - it returns an array of a fixed buffer size; It is unbounded, and ...
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 ...
2
votes
2answers
2k views

Safely getting the next element of a list

I'm looking for general review and improvements on this code that safely gets the next element of a list (and wraps to the first element if you exceed the list). It just seems a little excessive for ...
15
votes
1answer
1k views

CircularListCursor - an efficient circular cursor on any list

I have decided to create my own CircularListCursor, because I wanted some abstraction and a ListIterator<E> couldn't give ...
2
votes
1answer
2k views

Ring buffer in C tail pointer issue (for audio streaming)

I am currently writing an embedded application for audio streaming purposes. The embedded app will receive audio packets being sent over WiFi, buffer the packets, then send the audio data over to a ...
5
votes
1answer
549 views

Microcontroller ringbuffer

I'm pretty new to microcontrollers and C in general, so I thought asking here would be a good way not to get started with bad habits. ...