Suppose we have a function foo
that does something
to all the elements between *firsta
and *lastb
:
foo(RandomAccessIterator1 firsta,RandomAccessIterator1 lasta){
for (RandomAccessIterator1 it=firsta;it!=lasta+1;it++){
//here stuff happens...
}
}
question a): is there a way to skip an index firsta<i<lastb
by only
modifying the inputs to foo
--e.g. the random iterators,
in other words without changing foo
itself, just its input?
--Unfortunately the index I want to skip are not in the edges
(they are often deep between firsta
and lasta
) and foo
is a complicated divide&conquer algorithm that's not amenable
to being called on subsets of the original array the iterators
are pointing to.
question b): if doing a) is possible, what's the cost of doing that?
constant or does it depend on (lasta-firsta)
?