A
Arturo Cuebas
I've got a bunch of file_iterator<> (http://tinyurl.com/3uuxa)
begin/end pairs that point to various chunks in a file. It would be
super-cool, in my program, to be able to treat all of these ranges as
though they were one huge range. I'm envisioning something along the
lines of a library facility that provides an iterator type that
encapsulates a set of ranges and abstracts out code to handle
traversal through all of them as though all the little sets of ranges
were one big one.
Maybe this will help clarify:
int main(void)
{
vector<pair<file_iterator<>, file_iterator<> >
ranges(2);
ranges.at(0).first = file_iterator<>("somefile.txt");
ranges.at(0).second = ranges.at(0).first + 5;
ranges.at(1).first = ranges.at(0).second + 5;
ranges.at(1).second = ranges.at(1).first + 5;
// this is fictional
typedef single_range_emulating_iterator</*some stuff here*/>
sre_iterator;
sre_iterator begin(ranges);
sre_iterator end = begin.make_end(); // or something
// this results in a traversal through all the ranges.
for_each(begin, end, some_operation());
}
Is there such a thing? Is such a thing possible?
begin/end pairs that point to various chunks in a file. It would be
super-cool, in my program, to be able to treat all of these ranges as
though they were one huge range. I'm envisioning something along the
lines of a library facility that provides an iterator type that
encapsulates a set of ranges and abstracts out code to handle
traversal through all of them as though all the little sets of ranges
were one big one.
Maybe this will help clarify:
int main(void)
{
vector<pair<file_iterator<>, file_iterator<> >
ranges(2);
ranges.at(0).first = file_iterator<>("somefile.txt");
ranges.at(0).second = ranges.at(0).first + 5;
ranges.at(1).first = ranges.at(0).second + 5;
ranges.at(1).second = ranges.at(1).first + 5;
// this is fictional
typedef single_range_emulating_iterator</*some stuff here*/>
sre_iterator;
sre_iterator begin(ranges);
sre_iterator end = begin.make_end(); // or something
// this results in a traversal through all the ranges.
for_each(begin, end, some_operation());
}
Is there such a thing? Is such a thing possible?