Home

For discussion purposes, assume the vector ivec contains 67108864 (67
million elements) elements. Lets futher assume nstart and end equal
1008000 and 11088000 respectively.

The question. What's the _fastest_ way to erase element numbers less
than 1008000 and element numbers greater than 11088000. Current
approach.

typedef std::vector < int > INT_VEC ;

int main () {

int dummy( 0 ) ;
for ( INT_VEC::iterator it = ivec.begin(); it != ivec.end(); ) {
if ( dummy < nstart || dummy > end ) {
it = ivec.erase ( it ) ;
} else {
++ it ;
}
++ dummy ;
}

}

This is 'dog' slow. That said, I thinking it would be ideal if i
copied elements into a separate vector.

previous
next

Re: Dependency Loop seems unavoidable
Re: super() doesn't get superclass
Re: C API (embedded Python): How to get and set named variables
should we moderate comp.lang.c++
Re: parameter list notation
Krwinka
Mimo Wszystko
Fundacja Avalon
Fundacja Sloneczko
Mam Marzenie