GPS.Collections
1.2.0
See the version list below for details.
dotnet add package GPS.Collections --version 1.2.0
NuGet\Install-Package GPS.Collections -Version 1.2.0
<PackageReference Include="GPS.Collections" Version="1.2.0" />
paket add GPS.Collections --version 1.2.0
#r "nuget: GPS.Collections, 1.2.0"
// Install GPS.Collections as a Cake Addin #addin nuget:?package=GPS.Collections&version=1.2.0 // Install GPS.Collections as a Cake Tool #tool nuget:?package=GPS.Collections&version=1.2.0
GPS.Collections
Library of specialized data structures.
- (new) OrderedConcurrentDictionary -
IDictionary<TKey, TValue>
that guarantees order of data insertion is preserved on theKeys
collection and enumerator while maintaining thread-safe inserts and random access. - MatrixArray - Spacial data structure providing always-sorted direct access for integer-indexed data.
Installation
GPS.Collections is available through Nuget.
nuget install GPS.Collections
GPS.Collections.OrderedConcurrentDictionary<TKey, TValue>
IDictionary<TKey, TValue>
that guarantees order of data insertion is preserved on the Keys
collection and enumerator while maintaining thread-safe inserts and random access.
Additional Methods
/// <summary>
/// Reorders the data in the collection according the supplied selector,
/// IComparer and ReorderDirection specified.
/// </summary>
/// <param name="selector">Func of the selector.</param>
/// <param name="direction">ReorderDirection specifying the direction
/// to sort the data.</param>
public void Reorder(Func<(TKey Key, TValue Value), TKey> selector
, ReorderDirection direction = ReorderDirection.Ascending) { ... }
/// <summary>
/// Reorders the data in the collection according the supplied selector,
/// IComparer and ReorderDirection specified.
/// </summary>
/// <param name="selector">Func of the selector.</param>
/// <param name="comparer">IComparer instance that performs the test
/// to determine the ordinality of two datum in the collection.</comparer>
/// <param name="direction">ReorderDirection specifying the direction
/// to sort the data.</param>
public void Reorder(Func<(TKey Key, TValue Value), TKey> selector
, IComparer<TKey> comparer
, ReorderDirection direction = ReorderDirection.Ascending) { ... }
GPS.Collections.MatrixArray<T>
Benchmarks
Loading | Positive Random | Open-Ended Random | Find Last | Enumerate | Sum | Memory | |
---|---|---|---|---|---|---|---|
MatrixArray | 49 | 67 | 61 | 39 | 24 | 240 | 1494190 |
Dictionary | 38 | 28 | 28 | 0 | 7 | 101 | 668789 |
SortedDictionary | 409 | 421 | 464 | 25 | 28 | 1347 | 670201 |
Description of MatrixArray
The MatrixArray
is an auto-growing array of arrays that provide a contiguous indexing mechanism. At full depth, indices may be any Int32
value, both positive and negative. This allows for natural indexing of data without sliding offsets.
MatrixArray Usage
Negative Indices
var matrixArray = new MatrixArray<string>();
matrixArray[-1] = "negative one";
matrixArray[-2] = "negative two";
Console.WriteLine($"Range: {matrixArray.Lowest} to {matrixArray.Highest}");
// Range: -2 to -1
Sparse Indices
var matrixArray = new MatrixArray<string>();
matrixArray[-1000] = "negative one-thousand";
matrixArray[1000] = "one-thousand";
Console.WriteLine($"Range: {matrixArray.Lowest} to {matrixArray.Highest}");
// Range: -1000 to 1000
Console.WriteLine($"Count: {matrixArray.Count}");
// Count: 2001
Auto-growing
var matrixArray = new MatrixArray<string>();
matrixArray[-1] = "negative one";
matrixArray[1] = "one";
Console.WriteLine($"Count: {matrixArray.Count}");
// Count: 3
matrixArray[3] = "three";
Console.WriteLine($"Count: {matrixArray.Count}");
// Count: 5
matrixArray[2] = "two";
Console.WriteLine($"Count: {matrixArray.Count}");
// Count: 5
Add Range
var matrixArray = new MatrixArray<string>();
matrixArray[0] = "zero";
matrixArray.AddRange(new [] { "one", "two" } );
Console.WriteLine($"Range: {matrixArray.Lowest} to {matrixArray.Highest}");
// Range: 0 to 2
Add Range At
var matrixArray = new MatrixArray<string>();
matrixArray.AddRange(21, new [] { "twenty-one", "twenty-two" } );
Console.WriteLine($"Range: {matrixArray.Lowest} to {matrixArray.Highest}");
// Range: 21 to 22
IndexOf
var matrixArray = new MatrixArray<string>();
matrixArray[10] = "find me";
matrixArray.AddRange(new [] { "me too", "me three" } );
Console.WriteLine($"IndexOf: \"find me\" = {matrixArray.IndexOf("find me")}");
// IndexOf: "find me" = 10
Console.WriteLine($"IndexOf: \"me three\" = {matrixArray.IndexOf("me three")}");
// IndexOf: "me three" = 12
Note about LinkedArray
LinkedArray
was left in the package for backwards compatibility, but there is no
reason to use it for new code. Replacing it with MatrixArray
is a simple search-replace
process.
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 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. 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. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.