Looping lists are often implemented using arrays, which make them very fast and, by their nature, do not require dynamic resizing. You just need a quick check of the read and write indices to see if they have fallen from the end, and if so, then reset it is zero (or one, regardless).
However, they are commonly used for things like input buffers, where the data does not have real value after reading. Contact lists are of lasting importance, and new contacts will overwrite old contacts after filling out the list, which may be good if you do not rewrite your grandmother, who will leave you a lot of cash in her will.
I do not think that a linked list is the most efficient way for a circular buffer (original question).
The purpose of a circular buffer is speed, and the array simply cannot be beaten for speed in the context of a circular buffer. Even if you keep a pointer to your last element in the linked list, the array will still be more efficient. Lists have dynamic resizing capabilities (overhead) that are not needed for circular buffers. Having said that, I think the circular buffer is probably not a suitable structure for the application (contact list) that you mentioned.
RAL Apr 4 '09 at 2:52 2009-04-04 02:52
source share