Class ExtensionMethodsSet
Provides a set of extension methods to optimize enumerables operations on set.
public static class ExtensionMethodsSet
- Inheritance
-
ExtensionMethodsSet
- Inherited Members
Methods (11)
Except<T>(IEnumerable<T>, HashSet<T>)
Produces the set difference of this seq and hashset. This method is an optimized version of Enumerable.Except<T>.
public static IEnumerable<T> Except<T>(this IEnumerable<T> seq, HashSet<T> hashset) where T : class
Parameters
seqIEnumerable<T>A sequence of elements whose elements that are not also in
hashsetwill be returned.hashsetHashSet<T>An hashset of elements whose elements that also occur in
seqwill cause those elements to be removed from the returned sequence.
Returns
- IEnumerable<T>
A sequence that contains the set difference of the elements of
seqandhashset.
Type Parameters
TThe element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(seq.Count) time complexity.
Intersect<T>(HashSet<T>, HashSet<T>)
Produces the set of elements, intersection of this hashset and otherHashset. This method is an optimized version of Enumerable.Intersect<T>.
public static IEnumerable<T> Intersect<T>(this HashSet<T> hashset, HashSet<T> otherHashset)
Parameters
hashsetHashSet<T>An hashset of elements whose distinct elements that also appear in
otherHashsetwill be returned.otherHashsetHashSet<T>An hashset of elements whose distinct elements that also appear in
hashsetwill be returned.
Returns
- IEnumerable<T>
A sequence that contains the elements that form the set intersection of both hashsets.
Type Parameters
TThe code element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(otherHashset.Count) time complexity.
Intersect<T>(HashSet<T>, IEnumerable<T>)
Produces the set of elements, intersection of this hashset and seq. This method is an optimized version of Enumerable.Intersect<T>.
public static IEnumerable<T> Intersect<T>(this HashSet<T> hashset, IEnumerable<T> seq)
Parameters
hashsetHashSet<T>An hashset of elements whose distinct elements that also appear in
seqwill be returned.seqIEnumerable<T>A sequence of elements whose distinct elements that also appear in
hashsetwill be returned.
Returns
- IEnumerable<T>
A sequence that contains the elements that form the set intersection of the hashset and the sequence.
Type Parameters
TThe code element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(seq.Count) time complexity.
Intersect<T>(IEnumerable<T>, HashSet<T>)
Produces the set of elements, intersection of this seq and hashset. This method is an optimized version of Enumerable.Intersect<T>.
public static IEnumerable<T> Intersect<T>(this IEnumerable<T> seq, HashSet<T> hashset)
Parameters
seqIEnumerable<T>A sequence of elements whose distinct elements that also appear in
hashsetwill be returned.hashsetHashSet<T>An hashset of elements whose distinct elements that also appear in
seqwill be returned.
Returns
- IEnumerable<T>
A sequence that contains the elements that form the set intersection of the hashset and the sequence.
Type Parameters
TThe code element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(seq.Count) time complexity.
ToHashSetEx<T>(IEnumerable<T>)
Creates an hashset from a IEnumerable<T>.
public static HashSet<T> ToHashSetEx<T>(this IEnumerable<T> seq)
Parameters
seqIEnumerable<T>An IEnumerable<T> to create an hashset from.
Returns
- HashSet<T>
An hashset that contains the elements from the input sequence.
Type Parameters
TThe type of the elements of
seq.
Remarks
This method exists since NDepend v2018.1.1 because the .NET Fx v4.7.2 introduces a ToHashSet() extension method with the same signature as the one in the NDepend.API. As a consequence ambiguous call errors are emitted by the compiler when using ToHashSet() in a .NET fx v4.7.2 (or upper) environment. ToHashSet() can still be used as a static method ExtensionMethodsSet.ToHashSet(...). To avoid any problem, a straightforward solution is to replace "ToHashSet()" with "ToHashSetEx()" in all your .ndproj and .ndrules textual files that contain your code queries and rules.
ToHashSetEx<T>(IEnumerable<T>, IEqualityComparer<T>)
Creates an hashset from a IEnumerable<T>.
public static HashSet<T> ToHashSetEx<T>(this IEnumerable<T> seq, IEqualityComparer<T> equalityComparer)
Parameters
seqIEnumerable<T>An IEnumerable<T> to create an hashset from.
equalityComparerIEqualityComparer<T>The equality comparer on elements.
Returns
- HashSet<T>
An hashset that contains the elements from the input sequence.
Type Parameters
TThe type of the elements of
seq.
Remarks
This method exists since NDepend v2018.1.1 because the .NET Fx v4.7.2 introduces a ToHashSet() extension method with the same signature as the one in the NDepend.API. As a consequence ambiguous call errors are emitted by the compiler when using ToHashSet() in a .NET fx v4.7.2 (or upper) environment. ToHashSet() can still be used as a static method ExtensionMethodsSet.ToHashSet(...). To avoid any problem, a straightforward solution is to replace "ToHashSet()" with "ToHashSetEx()" in all your .ndproj and .ndrules textual files that contain your code queries and rules.
ToHashSet<T>(IEnumerable<T>)
Creates an hashset from a IEnumerable<T>.
[Obsolete("Use ToHashSetEx() extension method instead to avoid conflict with the .NET Fx v4.7.2 ToHashSet() extension method with same signature")]
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq)
Parameters
seqIEnumerable<T>An IEnumerable<T> to create an hashset from.
Returns
- HashSet<T>
An hashset that contains the elements from the input sequence.
Type Parameters
TThe type of the elements of
seq.
Remarks
The .NET Fx v4.7.2 introduces a ToHashSet() extension method with the same signature. As a consequence this method has been marked as obsolete since NDepend v2018.1.1 and it is advised to use ToHashSetEx<T>(IEnumerable<T>) instead, to avoid ambiguous call error emitted by the compiler.
ToHashSet<T>(IEnumerable<T>, IEqualityComparer<T>)
Creates an hashset from a IEnumerable<T>.
[Obsolete("Use ToHashSetEx() extension method instead to avoid conflict with the .NET Fx v4.7.2 ToHashSet() extension method with same signature")]
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq, IEqualityComparer<T> equalityComparer)
Parameters
seqIEnumerable<T>An IEnumerable<T> to create an hashset from.
equalityComparerIEqualityComparer<T>The equality comparer on elements.
Returns
- HashSet<T>
An hashset that contains the elements from the input sequence.
Type Parameters
TThe type of the elements of
seq.
Remarks
The .NET Fx v4.7.2 introduces a ToHashSet() extension method with the same signature. As a consequence this method has been marked as obsolete since NDepend v2018.1.1 and it is advised to use ToHashSetEx<T>(IEnumerable<T>, IEqualityComparer<T>) instead, to avoid ambiguous call error emitted by the compiler.
Union<T>(HashSet<T>, HashSet<T>)
Produces the set of elements, union of this thisHashset and otherHashset. This method is an optimized version of Enumerable.Union<T>.
public static IEnumerable<T> Union<T>(this HashSet<T> thisHashset, HashSet<T> otherHashset)
Parameters
thisHashsetHashSet<T>A sequence of elements whose distinct elements form the first set for the union.
otherHashsetHashSet<T>An hashset of elements whose distinct elements form the second set for the union.
Returns
- IEnumerable<T>
A sequence that contains the elements that form the set union of both hashsets, excluding duplicates.
Type Parameters
TThe code element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(otherHashset.Count) time complexity.
Union<T>(HashSet<T>, IEnumerable<T>)
Produces the set of elements, union of this hashset and seq. This method is an optimized version of Enumerable.Union<T>.
public static IEnumerable<T> Union<T>(this HashSet<T> hashset, IEnumerable<T> seq)
Parameters
hashsetHashSet<T>An hashset of elements whose distinct elements form the first set for the union.
seqIEnumerable<T>A sequence of elements whose distinct elements form the second set for the union.
Returns
- IEnumerable<T>
A sequence that contains the elements that form the set union of the hashset and the sequence, excluding duplicates.
Type Parameters
TThe code element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(seq.Count) time complexity.
Union<T>(IEnumerable<T>, HashSet<T>)
Produces the set of elements, union of this seq and hashset. This method is an optimized version of Enumerable.Union<T>.
public static IEnumerable<T> Union<T>(this IEnumerable<T> seq, HashSet<T> hashset)
Parameters
seqIEnumerable<T>A sequence of elements whose distinct elements form the second set for the union.
hashsetHashSet<T>An hashset of elements whose distinct elements form the first set for the union.
Returns
- IEnumerable<T>
A sequence that contains the elements that form the set union of the sequence and the hashset, excluding duplicates.
Type Parameters
TThe code element type of the elements of the hashset and the sequence.
Remarks
This extension method has a O(seq.Count) time complexity.