Piotr wrote:[color=blue]
> Can I create a Random Access Iterator which start at a certain index
> and end at a certain index of a container?[/color]
yes.
[color=blue]
> I go thru this page, but I can't find an example.
>
http://www.sgi.com/tech/stl/random_a...rator_tag.html[/color]
#include <vector>
int main() {
const size_t size = 128;
std::vector<int> v(size, 3);
// create random access iterator
std::vector<int>::iterator iter = v.begin();
// Access objects with "random" offset (less than size)
iter += 6;
}
[color=blue]
> Any pointer to an example is appreciated.[/color]
Does the above help?
Or do you want to *implement* a random iterator?
Not all containers support random access, in which case you can create a
random access iterator class by overriding +, +=, -, -= etc, and using
the ++ and -- operator of the forward and reverse iterators of the
underlying type, in a for loop.
Ben Pope
--
I'm not just a number. To many, I'm known as a string...