Opened 13 years ago

Last modified 13 years ago

#643 new request

Circular Iterator Adaptor

Reported by: Peter Owned by: Jari Häkkinen
Priority: major Milestone: yat 0.x+
Component: utility Version: trunk
Keywords: Cc:

Description

This iterator should work exactly as its base iterator with the difference that when it increments to the end of the container we gets to the begin instead.

For example if I have a vector(100) I wanna be able to iterate from vector.begin()+50 all the way to the end, continue from the beginning and end at e.g. at vector.begin()+50. This should be possible via

algorithm(CIT(vector.begin()+50), CIT(vector.begin()+50));

The adaptor probably needs to hold a reference to the container but I leave those decisions for later.

Change History (1)

comment:1 Changed 13 years ago by Peter

There's clearly an issue with the suggested code in description. In

algorithm(CIT(vector.begin()+50), CIT(vector.begin()+50));

argument one and argument two are equal, and since many algorithms are like

algorithm(first, last)
{
  while(first!=last) {
    <do sometimes>
  }
}

the while loop would exit immediately instead of acting on the range.

Note: See TracTickets for help on using tickets.