kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #42004
Re: Multiple delete in dialog_spice_model.cpp
Yeah, the guys that wrote the standard template library could have won awards in obfuscation.
> On 30 Aug 2019, at 21:17, Seth Hillbrand <seth@xxxxxxxxxxxxx> wrote:
>
> On 2019-08-30 15:49, Sylwester Kocjan wrote:
>
>> m_schfields->erase( std::remove_if(
>> m_schfields->begin(), m_schfields->end(),
>> [&]( const SCH_FIELD& f ) { return f.GetName()
>> == spiceField; } ), m_schfields->end() );
>
>
>> My question is, why deletion is repeated: at first there is called
>> remove_if(), and later erase(), which will delete
>> all the fields behind the removed one. From my point of view it looks
>> like remove_if() only should be enough.
>
>
> remove_if() re-orders the container and returns the iterator that points to the first matching element. erase() removes all elements from this iterator through the end of the container.
>
> See https://en.wikipedia.org/wiki/Erase%E2%80%93remove_idiom
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
References