[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: kdebase/kioslave/smtp
From:       André Wöbbeking <Woebbeking () web ! de>
Date:       2003-04-26 18:16:47
[Download RAW message or body]

On Saturday 26 April 2003 19:09, Antonio Larrosa Jiménez wrote:
> Also, the STL has other leaks in other areas different from the
> documentation too, for example, how do you remove an element from a
> vector by value ? Or how do you get an iterator that points to an
> element in the vector which has a specific value ? You have to
> iterate through all the vector, which is not nice at all (if you know
> any other way to do it, I'll be glad to hear it :) )

You have to use algorithms, as most thinks in STL are implemented 
generic.

it = std::find(vec.begin(), vec.end(), bla)

vec.erase(it)

and without find - this looks indeed a bit strange :-)

vec.erase(std::remove(vec.begin(), vec.end(), bla), vec.end())


Cheers,
André

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic