MultiKeyLookup 1.0.4

dotnet add package MultiKeyLookup --version 1.0.4
                    
NuGet\Install-Package MultiKeyLookup -Version 1.0.4
                    
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="MultiKeyLookup" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MultiKeyLookup" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="MultiKeyLookup" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MultiKeyLookup --version 1.0.4
                    
#r "nuget: MultiKeyLookup, 1.0.4"
                    
#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.
#:package MultiKeyLookup@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MultiKeyLookup&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=MultiKeyLookup&version=1.0.4
                    
Install as a Cake Tool

multi-key-lookup

A data structure that allows indexing by multiple fields for fast data access.

Basic Usage

Pass the data and an array of index fields to the constructor. Get the data with a field and value.


public class DataClass
{
  public int A { get; set; }
  public int B { get; set; }
  public int C { get; set; }
}

public void Get() 
{
    var Data = new DataClass[] {new DataClass() { A = 1, B = 2, C = 3 }, 
    new DataClass() { A = 1, B = 3, C = 2 }, new DataClass(){ A = 3, B = 2, C = 1}};
    var Indexed = new MultiKeyLookup(Data, ("A", k => k.A), ("B", k => k.B));

    IEnumerable<DataClass> A1 = Indexed.get('A', 1);
    IEnumerable<DataClass> B2 = Indexed.get('B', 2);

    //prints [{a: 1, b: 2, c: 3}, {a: 1, b: 3, c: 2}]
    Console.WriteLine(A1);

    //prints [{a: 1, b: 2, c: 3}, {a: 3, b: 2, c: 1}]
    Console.WriteLine(B2);
}

API

new MultiKeyLookup(data, ...indexes); //data and indexes are optional
Count; //the number of data entries
Indexes; //the number of indexes
Values; //gets an iterable of values
AddIndex((field, fieldSelector)); //indexes the data by another index
RemoveIndex(field); //removes an index
Add(...data); //adds data
ContainsKey(field, key, fieldSelector); //does the data exist by field and key, fieldSelector needed for no index
TryGetValue(field, key, fieldSelector); //gets the data by field and key, fieldSelector needed for no index
GetValueOrDefault(field, key, fieldSelector); //get a single value or default by field and key, fieldSelector needed for no index
Get(field, key, fieldSelector); //gets the data by field and key, fieldSelector needed for no index
Remove(field, key, fieldSelector); //removes the data by field and key, fieldSelector needed for no index
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • 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.

Version Downloads Last Updated
1.0.4 116 2/13/2025
1.0.3 350 2/24/2023
1.0.2 505 6/27/2021
1.0.1 484 6/27/2021
1.0.0 497 6/25/2021

publish 1.0.4 net9