T
Thomas Kowalski
Hi everyone,
I would like if there is an easy way to get the number of elements left
after an given iterator?
I have an interator called it somethere between beginning and end of an
list / map and want to know how often I have to call ++it before I
arrive at the end of the list. Means how many elements are left after
the given iterator it. My first solution (see below) is quite
inefficent.
int restsize()
{
int i=0;
T::iterator it2 = it;
for ( ;it2 != somelistormap.end(); ++it2)
{
++i;
}
return i;
}
I would like if there is an easy way to get the number of elements left
after an given iterator?
I have an interator called it somethere between beginning and end of an
list / map and want to know how often I have to call ++it before I
arrive at the end of the list. Means how many elements are left after
the given iterator it. My first solution (see below) is quite
inefficent.
int restsize()
{
int i=0;
T::iterator it2 = it;
for ( ;it2 != somelistormap.end(); ++it2)
{
++i;
}
return i;
}