Tedd.HashSetExtensions
1.0.2
.NET Core 2.0
This package targets .NET Core 2.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.1
This package targets .NET Framework 4.6.1. The package is compatible with this framework or higher.
dotnet add package Tedd.HashSetExtensions --version 1.0.2
NuGet\Install-Package Tedd.HashSetExtensions -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tedd.HashSetExtensions" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tedd.HashSetExtensions --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tedd.HashSetExtensions, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tedd.HashSetExtensions as a Cake Addin #addin nuget:?package=Tedd.HashSetExtensions&version=1.0.2 // Install Tedd.HashSetExtensions as a Cake Tool #tool nuget:?package=Tedd.HashSetExtensions&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Tedd.HashSetExtensions
.Net extension methods for ToHashSet<T>().<br /> All methods implemented with and without both selector and comparer. Special handling of Array and List to avoid enumeration overhead. In line with how ToDictionary is implemented in .Net source code.
Examples
All methods supports selector. A selector is used to pick or transform the object before it is added to the hash.
Selector example
var dic = new Dictionary<string, int>();
dic.Add("A", 1);
dic.Add("B", 2);
// A dictionary consists of KeyValuePair and we pick the Key portion of that for our HashSet
var hashSet = dic.ToHashSet(s => s.Key);
dic.Add("CC", 2);
// Or we can have more complex logic
var hashSet2 = dic.ToHashSet(s => {
if (s.Key == "CC")
return "C";
return s.Key;
});
Methods
ienumerable.ToHashSet()
var list = new List<string>();
list.Add("A");
list.Add("B");
var hashSet = list.ToHashSet(); // No selector needed
var thisIsTrue = hashSet.Contains("A");
var thisIsFalse = hashSet.Contains("C");
// Add B again
list.Add("B");
var hashSet2 = list.ToHashSet(s => s); // Using selector
// HashSet only cointains 2 items because duplicates are ignored
var thisIsTwo = hashSet2.Count;
ienumerable.ToHashSet(selector, comparer)
var list = new List<string>();
list.Add("a");
list.Add("b");
var hashSet = list.ToHashSet(s => s, StringComparer.InvariantCultureIgnoreCase);
// HashSet now contains: a, b
var thisIsTrue = hashSet.Contains("a");
var thisIsAlsoTrue = hashSet.Contains("A");
hashset.ContainsRange(ienumerable)
var list = new List<string>();
list.Add("A");
list.Add("B");
list.Add("C");
var hashSet = list.ToHashSet(s => s);
// HashSet now contains: A, B, C
var otherList = new List<string>();
otherList.Add("A");
otherList.Add("B");
var thisIsTrue = hashSet.ContainsRange(otherList);
hashset.AddRange(ienumerable)
var list1 = new List<string>();
list1.Add("A");
list1.Add("B");
var hashSet = list1.ToHashSet(s => s);
// HashSet now contains: A, B
var list2 = new List<string>();
list.Add("C");
list.Add("D");
hashSet.AddRange(list2);
// HashSet now contains: A, B, C, D
var thisIsTrue = hashSet.Contains("D");
hashset.RemoveRange(ienumerable)
var list1 = new List<string>();
list1.Add("A");
list1.Add("B");
list1.Add("C");
list1.Add("D");
var hashSet = list1.ToHashSet();
// HashSet now contains: A, B, C, D
var list2 = new List<string>();
list.Add("A");
list.Add("B");
hashSet.RemoveRange(list2);
// HashSet now contains: B, C
var thisIsFalse = hashSet.Contains("A");
var thisIsAlsoFalse = hashSet.Contains("B");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 is compatible. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 2.0
- No dependencies.
-
.NETCoreApp 2.1
- No dependencies.
-
.NETCoreApp 3.0
- No dependencies.
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.7.1
- No dependencies.
-
.NETFramework 4.7.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Tedd.HashSetExtensions:
Package | Downloads |
---|---|
Tedd.DictionaryUtils
Extensions to Dictionary<TKey, TValue> |
GitHub repositories
This package is not used by any popular GitHub repositories.
Contains for array, list and ienumerable