1/24
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
HashSet
A generic collection in System.Collections.Generic that stores unique elements and provides efficient membership testing and set-based operations. Domain: C# → .NET → System.Collections.Generic → Sets
T in HashSet
The generic type parameter that specifies the type of elements stored in the HashSet.
new HashSet
Creates an empty HashSet
new HashSet
Creates a HashSet
new HashSet
Creates an empty HashSet
HashSet Initializer
Syntax that creates a HashSet
set.Count
Gets the number of unique elements currently contained in the HashSet.
set.Add(item)
Attempts to add an element to the HashSet and returns true if the element was added or false if an equivalent element was already present.
set.Remove(item)
Attempts to remove the specified element and returns whether the element was found and removed.
set.Contains(item)
Determines whether the HashSet contains an element equivalent to the specified item.
set.Clear()
Removes all elements from the HashSet.
HashSet Uniqueness
A HashSet
HashSet Equality Comparer
The comparer used by a HashSet to determine whether two elements should be treated as equal.
set.Comparer
Gets the IEqualityComparer
set.UnionWith(other)
Modifies the current HashSet so that it contains every element present in either the current set or the specified collection.
set.IntersectWith(other)
Modifies the current HashSet so that it contains only elements present in both the current set and the specified collection.
set.ExceptWith(other)
Modifies the current HashSet by removing elements that also occur in the specified collection.
set.SymmetricExceptWith(other)
Modifies the current HashSet so that it contains elements present in either set but not in both.
set.IsSubsetOf(other)
Determines whether every element in the current HashSet is contained in the specified collection.
set.IsProperSubsetOf(other)
Determines whether the current HashSet is a subset of the specified collection and the specified collection contains at least one additional element.
set.IsSupersetOf(other)
Determines whether the current HashSet contains every element in the specified collection.
set.IsProperSupersetOf(other)
Determines whether the current HashSet is a superset of the specified collection and contains at least one additional element.
set.SetEquals(other)
Determines whether the current HashSet and the specified collection contain the same elements.
set.Overlaps(other)
Determines whether the current HashSet and specified collection share at least one common element.
HashSet vs List
List