What interface for "ISet"

  • Thread starter Thread starter Helge Jensen
  • Start date Start date
Daniel said:
Out of curiosity, does the v2 ICollection<T> satisfy your requirements?

I havent looked at the standard library for C# with generics yet, but if
your description is accurate, then yes, it would satisfy the requirements.

The current ICollection only exposes size Count and IEnumerable, which
prevents user from even asking "is foo in bar" without doing an enumeration.
While I would like to see set semantics put in stone, it seems to me this
generic ICollection suits the needs and a forward looking generic ISet
interface would be little more than a marker.

Actually, interfaces are often little more than "markers". But, they are
nice to have in the std-library, so different implementations can be
passed between components through the interface.
 
Nick said:
Hello Helge,

Hello, sry for the long reply-time, I've been out-of town without
internet since wednessday.
I apologize for not understanding your requirements. You didn't need an
efficient implementation of a set. You wanted an interface that was defined
in the framework.

No problemo. I must have been too vague in the question,... you weren't
the only one to misunderstand me.

BTW: The implementation is now consistently faster than
System.Collections.Hashtable, and uses about half the memory (hardly
surprising, since it doesn't have to store Values).

I have also written a similar implementation of IDictionary, which is
also faster than Hashtable, but has about the same memory-usage.
As you probably guessed, I am powerless to modify the framework. (I'm not
sure I'd agree with you about the need to.)

I wouldn't expect changes, or even additions, to the framework to be
easily accepted. Having a steady base for developers has a merit of it's
own.
If you'd like to see a new interface added to the framework, send a note to
MSWish and cross your fingers.

Thanks. As Daniel O'Connel points out, the ICollection<T> has appently
been extended with Add, Remove and Contains. So maybe there would be
hope for having some kind of change in the framework, although I dont
expect ICollection to ever change since that would invalidate old code.
 
Back
Top