Gapotchenko.FX.Collections
2022.1.4
Prefix Reserved
See the version list below for details.
dotnet add package Gapotchenko.FX.Collections --version 2022.1.4
NuGet\Install-Package Gapotchenko.FX.Collections -Version 2022.1.4
<PackageReference Include="Gapotchenko.FX.Collections" Version="2022.1.4" />
paket add Gapotchenko.FX.Collections --version 2022.1.4
#r "nuget: Gapotchenko.FX.Collections, 2022.1.4"
// Install Gapotchenko.FX.Collections as a Cake Addin #addin nuget:?package=Gapotchenko.FX.Collections&version=2022.1.4 // Install Gapotchenko.FX.Collections as a Cake Tool #tool nuget:?package=Gapotchenko.FX.Collections&version=2022.1.4
Overview
The module was started by borrowing an implementation of ConcurrentHashSet<T>
from Mr. Bar Arnon.
Other than that, the module provides polyfills for missing functionality in .NET.
ConcurrentHashSet<T>
ConcurrentHashSet<T>
provided by Gapotchenko.FX.Collections
is a thread-safe implementation of HashSet<T>
.
AssociativeArray<TKey, TValue>
AssociativeArray<TKey, TValue>
provided by Gapotchenko.FX.Collections
is a drop-in replacement for Dictionary<TKey, TValue>
that can handle null
keys.
In contrast, stock Dictionary<TKey, TValue>
cannot work with null
keys and throws an exception whenever a null
key is encountered.
Due to such an artificial narrowing of the key space, it becomes hardly possible to solve some kinds of tasks with Dictionary<TKey, TValue>
.
AssociativeArray<TKey, TValue>
resolves that by supporting a full space of keys without opinionated exclusions.
AddRange<T>(IEnumerable<T>) for Collections
AddRange
is a highly demanded operation that allows to add a sequence of elements to the end of a collection.
Like this:
using Gapotchenko.FX.Collections.Generic;
var collection = new Collection<int>();
…
collection.AddRange(numbers.Where(x => x % 2 == 0)); // add even numbers
IsNullOrEmpty() for Containers
System.String
class provides a convenient IsNullOrEmpty
primitive.
Gapotchenko.FX.Collections
extends availability of that primitive by providing IsNullOrEmpty()
extension method for other container types.
Here is an example:
using Gapotchenko.FX.Collections.Generic;
class Method
{
List<Argument> m_Arguments;
public bool HasArguments => !m_Arguments.IsNullOrEmpty();
…
}
The use of an extension method for a null check may look controversial at first,
but since the method starts with IsNull…
prefix,
it immediately communicates its purpose and function.
Other benefits include automatic type inference and semantic locality.
Polyfills
KeyValuePair Polyfill
.NET provides a versatile KeyValuePair<TKey, TValue>
struct and suggests a default way for its instantiation:
new KeyValuePair<TKey, TValue>(key, value)
Which is, well, not handy as it often comes to this:
new KeyValuePair<BindingManagerDataErrorEventHandler, ICom2PropertyPageDisplayService>(key, value)
Gapotchenko.FX.Collections
provides a better way to instantiate a KeyValuePair<TKey, TValue>
struct:
using Gapotchenko.FX.Collections.Generic;
KeyValuePair.Create(key, value)
It leverages the automatic type inference provided by some .NET languages like C#.
PriorityQueue polyfill
PriorityQueue<TElement, TPriority>
provided by Gapotchenko.FX.Collections
module is an implementation of the prioritized queue introduced since .NET 6.
The polyfill makes it available to all supported .NET versions.
Deconstruction
Gapotchenko.FX.Collections
module comes with a function for KeyValuePair<TKey, TValue>
deconstruction, so you can write this:
using Gapotchenko.FX.Collections.Generic;
void ProcessMap(IDictionary<string, int> map)
{
foreach (var (key, value) in map)
{
…
}
}
instead of a more verbose variant:
void ProcessMap(IDictionary<string, int> map)
{
foreach (var i in map)
{
var key = i.Key;
var value = i.Value;
…
}
}
A little detail, but sometimes it matters a lot when you are amid the heat of the code.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 is compatible. net472 is compatible. net48 was computed. 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. |
-
.NETCoreApp 2.0
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
.NETCoreApp 2.1
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
.NETCoreApp 3.0
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
.NETFramework 4.6
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
- System.ValueTuple (>= 4.5.0)
-
.NETFramework 4.7.1
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
.NETFramework 4.7.2
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
.NETStandard 2.0
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
.NETStandard 2.1
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
net5.0
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
net6.0
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
-
net7.0
- Gapotchenko.FX (>= 2022.1.4)
- Gapotchenko.FX.Linq (>= 2022.1.4)
- Gapotchenko.FX.Threading (>= 2022.1.4)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on Gapotchenko.FX.Collections:
Package | Downloads |
---|---|
Gapotchenko.FX.Threading
Provides complementary primitives for multithreaded and asynchronous programming in .NET. |
|
Gapotchenko.FX.Profiles.Core
Represents the Core profile of Gapotchenko.FX. |
|
Gapotchenko.FX.Math.Geometry
The module provides primitives and operations for geometry math. |
|
Gapotchenko.FX.Math.Combinatorics
Provides math operations for combinatorics. |
|
Gapotchenko.FX.Math.Topology
The module provides data structures and primitives for working with abstract topologies. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2024.1.3 | 1,164 | 11/10/2024 |
2022.2.7 | 1,757 | 5/1/2022 |
2022.2.5 | 1,497 | 5/1/2022 |
2022.1.4 | 1,502 | 4/6/2022 |
2021.2.21 | 1,582 | 1/21/2022 |
2021.2.20 | 1,541 | 1/17/2022 |
2021.1.5 | 821 | 7/6/2021 |
2020.2.2-beta | 398 | 11/21/2020 |
2020.1.15 | 733 | 11/5/2020 |
2020.1.9-beta | 489 | 7/14/2020 |
2020.1.8-beta | 468 | 7/14/2020 |
2020.1.7-beta | 520 | 7/14/2020 |
2020.1.1-beta | 542 | 2/11/2020 |
2019.3.7 | 810 | 11/4/2019 |
2019.2.20 | 782 | 8/13/2019 |
2019.1.151 | 853 | 3/30/2019 |