
15 Apr
2004
15 Apr
'04
2:37 a.m.
I like your suggestion, Roland. Here is my adaptation (I will have to add credits and copyright later). It counts wraps as you suggest. I found it easier to implement and understand by basing it on an integral offset from a base. It all becomes pretty simple by calculating a "realposition" which is wraps*size+position. This is like a virtual index into an infinitely long sequence. For the constructor, you give a pair of iterators and an optional offset, which defaults to 0. I think this covers all uses. Since the realposition can easily exceed an int, I decided to make this a separate parameter "offset_t" which defaults to int. Included is the iterator, a Ring class based on it, and a small test.