Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set: hasItem vs. hasIndex

23 views
Skip to first unread message

ErichSt

unread,
May 13, 2013, 9:58:10 AM5/13/13
to
Recently I've been hit by a large run-time penalty when I was using hasItem() to check for the existence of items in a large Set (~500.000 items).

Checking for the existence of 1.000 items with hasItem() took 20+ seconds.
Checking the same with hasIndex() took less than 0.01 seconds.

While I do understand that in the general case, hasItem() may take longer than hasIndex(): in the case of Set, shouldn't those two methods behave the same?

Glenn Knickerbocker

unread,
May 13, 2013, 4:11:42 PM5/13/13
to
On 5/13/2013 9:58 AM, ErichSt wrote:
> While I do understand that in the general case, hasItem() may take
> longer than hasIndex(): in the case of Set, shouldn't those two
> methods behave the same?

Well, the doc does say they're inherited from Table, not overridden by
Set. But yeah, it sure would be nice--in SetCollection, all the methods
that work on items could just be forwarded to their index counterparts:

allItems -> allIndexes
hasItem -> hasIndex
index -> at
removeItem -> remove

Similarly, in Bag, allIndex could be forwarded to allAt.

�R
0 new messages