« Return to Thread: set.empty() method

Re: set.empty() method

by Mark S. Miller-2 :: Rate this Message:

| View in Thread

clear() is ok. Also, java.util.Map and java.util.Set use clear() so it would also be familiar to many people.

Perhaps deleteAll() would be more mnemonic, as its relationship with delete() would be obvious?

On Tue, Feb 14, 2012 at 10:39 PM, Adam Shannon <adam@...> wrote:
I'd agree with using clear() and isEmpty() with their respective actions.

On Wed, Feb 15, 2012 at 00:37, Brendan Eich <brendan@...> wrote:
> Good idea, but I suggest an unambiguous verb instead of an
> adjective-or-verb: clear.
>
> "empty" is often used for the predicate, in naming conventions that eschew
> "isEmpty" and "emptyp" patterns.
>
> /be
>
>
> Peter Michaux wrote:
>>
>> If some piece of code needs to empty a set, it would be good to do
>> that in a single call
>>
>>     set.empty();
>>
>> Otherwise we might be left doing the following which could be very
>> inefficient.
>>
>>     set.forEach(function(element) {
>>         set['delete'](element);
>>     });
>>
>> Peter
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@...
>> https://mail.mozilla.org/listinfo/es-discuss
>>
> _______________________________________________
> es-discuss mailing list
> es-discuss@...
> https://mail.mozilla.org/listinfo/es-discuss



--
Adam Shannon
Developer
University of Northern Iowa
Sophomore -- Computer Science B.S. & Mathematics
http://ashannon.us



--
    Cheers,
    --MarkM

_______________________________________________
es-discuss mailing list
es-discuss@...
https://mail.mozilla.org/listinfo/es-discuss

 « Return to Thread: set.empty() method