0

Possible Duplicate:
Does a standard implementation of a Circular List exist for C++?

Is there ready a template class in some c++ library that is some kind of a loop: A liked list where the last node references the first one.

Admittedly this wouldn't always be a practical class to use since there couldn't exist a end() iterator nor a well defined begin() iterator. But I could really have use for one and I was hoping that I wouldn't have to code it myself.

Edit:

Thank you both (Vivek Goel and madmik3) and for your answers, but unfortunately they have nothing to do with my question (I suggest http://en.wikipedia.org/wiki/Linked_list to you both). I also found the same question here, didn't find it yesterday. I apologise for posting the same question.

Community
  • 1
  • 1
petter
  • 1,765
  • 18
  • 22
  • It's called a **circular linked list**. – Pete Becker Oct 20 '12 at 21:33
  • 1
    @petter I am still curious why the two answers have nothing to do with what you need? They seem to be perfect answers? – jogojapan Oct 21 '12 at 10:14
  • They are not liked. Their iterators do not loop. There is a risk of writing over nodes and pointers may then not point to what you would expect them to point at. I know that you could make a circular linked list wrapper using circular buffer, but I don't see any advantage in doing so. – petter Oct 22 '12 at 04:45

2 Answers2

1

What about Circular Buffer from boost http://www.boost.org/doc/libs/1_51_0/libs/circular_buffer/doc/circular_buffer.html

Griwes
  • 8,805
  • 2
  • 43
  • 70
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
0

Boost has a circular buffer.

http://www.boost.org/doc/libs/1_51_0/libs/circular_buffer/doc/circular_buffer.html

You can also see sample code here:

http://en.wikipedia.org/wiki/Ring_buffer

Griwes
  • 8,805
  • 2
  • 43
  • 70
madmik3
  • 6,975
  • 3
  • 38
  • 60