Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `HashSet<T>.IsSubsetOf()` and `HashSet<T>.IsProperSubsetOf()`

Tags:

What is the difference between this two method calls?

  • HashSet<T>.IsSubsetOf()
  • HashSet<T>.IsProperSubsetOf()
like image 368
Flovdis Avatar asked Jul 30 '14 16:07

Flovdis


People also ask

What is the difference between HashSet T and list T >?

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).

Why is HashSet faster than list C#?

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.

Why is HashSet faster than list?

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.

What is superset C#?

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 .


1 Answers

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

like image 163
ahruss Avatar answered Sep 20 '22 00:09

ahruss