|
Boost Users : |
From: Martin Wartens (martin.wartens_at_[hidden])
Date: 2004-12-01 11:11:42
Jeff Flinn <TriumphSprint2000 <at> hotmail.com> writes:
> A third solution?: (untested)
>
> const_iterator_type wrapper::erase( const_iterator_type aItr )
> {
> thismaptype::iterator lItr = thismap.find( aItr->first );
>
> if( lItr == thismap.end() ) throw something;
>
> return thismap.erase( lItr );
> }
You are right, for a map this would be much better than the distance solution,
but it is still basically the same problem: You are searching an element that
you already know. For a map the overhead is not so big, for containers like
list it really hurts.
Thanks for your effort,
Martin Wartens
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net