开发者

HashSet equality c#

I have a HashSet with it's own EqualityComparer, but I am wondering if a simple count of both sets is used before checking each element?

I thought I would be able t开发者_JAVA百科o answer this for myself in Reflector but I couldn't find any override of Equals in there.

Cheers,

Berryl

EDIT ==========

As Hans noted, it it the comparison of two sets that I am interested in, as part of an override of Equals in a class that has a HashSet as a property?


You are mixing it up. Implementing your own IEqualityComparer<> is useful to compare the elements you put in the HashSet. The Count property would only ever be useful if you want to compare the sets. Two very different things. There is no default implementation of Equals(). The HashSet.SetEquals() method indeed first checks the Count properties, if possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜