What is the difference between a circular buffer and a circular list?

What is the difference between a circular buffer and a circular linked list?

What is the purpose of the Ring Buffer associated with the circular list, cannot, or vice versa?

+4
source share
1 answer

The ring buffer is a single continuous block of memory that contains your elements, and when you reach the end, you return to the beginning:

+----------------------+ | | +-->| a | b | c | d |--+ === increasing memory ===> 

A circular linked list, due to the nature of the linked list, does not have to be contiguous, so all items can be scattered across memory. It simply obeys what the elements for the loop are:

 +---------| d |<-----------------+ | | +-->| a |------------->| b |--+ | | | +-----------------+ | | | +-->| c |------------+ === increasing memory ===> 

A circular linked list has the same advantage over a circular buffer that a linked list has a fixed array. It may vary in size, and you can insert and remove items without shuffling.

The disadvantages are similar as well, there is no access to the O (1) array and increased work if you expand or shorten the list.

A buffer buffer is usually used when you know the maximum permissible entries in it or not against its restriction. For example, if you have a communication protocol that can throttle the sending side when the buffer is full, which allows you to get the time of the receiving side.

An example with a circular linking list would be a list of processes in the operating system where you should be able to add or remove processes, but you do not care about the head of the list, but only about the current item.

+5
source

All Articles