← Back to team overview

dolfin team mailing list archive

Re: RFC: remove (container.size() == 0) idiom

 

On 1 March 2012 13:20, Marco Morandini <morandini@xxxxxxxxxxxxxx> wrote:
> On 03/01/2012 09:46 AM, Anders Logg wrote:
>>>
>>> >  For consistency, I suggest using empty() everywhere. I'd be happy for
>>> >  you to make the changes and push a branch to Launchpad.
>>
>> Me too.
>
>
> lp:~morandini/dolfin/sizetoempty
>

Thanks. I've pushed your changes to lp:dolfin.

Garth

> It was more painful and intrusive than I thought it would have been:
> I had to add emtpy() methods to all the vector wrappers,
> to MeshFunction<T> and to MeshValueCollection<T>.
>
> Beside the above additions, the branch
> changes
>
> c.size() == 0  into c.emtpy()
> c.size() != 0 into !c.empty()
>
> and
>
> c.size() > 0 into !c.empty()
>
> I've overlooked the last idiom during my first pass.
> Hope to have caught all of them.
>
> My toy application still works after applying the patch.
> I've not finished running dolfin's  test (got bored during the demo runs),
> but at least all the unit tests and some demos  works.
>
> Marco
>


References