What is the difference between this two method calls?
HashSet<T>.IsSubsetOf()
HashSet<T>.IsProperSubsetOf()
A HashSet<T> is a class designed to give you O(1) lookup for containment (i.e., does this collection contain a particular object, and tell me the answer fast). A List<T> is a class designed to give you a collection with O(1) random access than can grow dynamically (think dynamic array).
The main difference between HashSet and List is that the list can contain duplicate elements, though both are used to store unique values. HashSet is much faster than List collection because HashSet lazily initializes underlying data structures.
The result clearly shows that the HashSet provides faster lookup for the element than the List. This is because of no duplicate data in the HashSet. The HashSet maintains the Hash for each item in it and arranges these in separate buckets containing hash for each character of item stored in HashSet.
A superset of set A is a set that contains all of the elements of set A. A proper superset of A is a set that contains all of the elements of A but is not equal to A .
See here
If the current set is a proper subset of other, other must have at least one element that the current set does not have.
vs here
If other contains the same elements as the current set, the current set is still considered a subset of other.
The difference is set.IsSubsetOf(set) == true
, whereas set.IsProperSubsetOf(set) == false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With