Dictionary<TKey, TValue>.KeyCollection Class
implements the contains
through extension method from IEnumerable
, which is O(n)
why doesn't it have a native one with O(1)? it's kind of HashSet isn't it?
Dictionary<TKey, TValue>.KeyCollection Class
implements the contains
through extension method from IEnumerable
, which is O(n)
why doesn't it have a native one with O(1)? it's kind of HashSet isn't it?
It does implement its own Contains. You can't implement an interface through an extension method. Note that it implements it explicitly, which means you first have to cast it to ICollection
to use it.