IEnumerableTrie 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package IEnumerableTrie --version 1.0.0
NuGet\Install-Package IEnumerableTrie -Version 1.0.0
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="IEnumerableTrie" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IEnumerableTrie --version 1.0.0
#r "nuget: IEnumerableTrie, 1.0.0"
#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 IEnumerableTrie as a Cake Addin
#addin nuget:?package=IEnumerableTrie&version=1.0.0

// Install IEnumerableTrie as a Cake Tool
#tool nuget:?package=IEnumerableTrie&version=1.0.0

C# implementation of a Trie (prefix tree) that is IEnumerable. You may conduct a prefix tree and not have to run on the trie all the way to it's end - just for the amount of results you need. This is perfect for autocomplete or any other scenario where you may want a fixed amount of results yielded in every search.

Usage

You can go ahead and use IEnumerableTrie.Trie. all you need to do is implement "IHasStringKeys" in the class you want to save in the Trie. example:

public class Stock : IHasStringKeys
    {
        public string Symbol { get; set; }
        public string Name { get; set; }
        public string LastSale { get; set; }
        public string MarketCap { get; set; }

        public string[] Keys { get { return new[] {Symbol.ToLower(), Name.ToLower()}; } }

        public override string ToString()
        {
            return String.Format("{0} ({1}). Last Sale: {2}, MarketCap: {3}", Name, Symbol, LastSale, MarketCap);
        }
    }

Once you did, you can create your Trie:

IEnumerable<Stock> stocks = LoadStocks("NasdaqCompanyList.csv");
Trie<Stock> trie = new Trie<Stock>(stocks);

// Search for a stock by prefix. as this is Ienumrable, we don't iterate over the Trie yet:
IEnumerable<Stock> results = trie.GetValuesByPrefix("micro");
// we only want the first 100, and will only iterate over the Trie until we find 100 max
foreach(var stock in results.Take(10))
{
    Console.WriteLine(stock);
}

There are a few Simple implementations ready to be used:

KeyValueTrie

A Trie that uses the key as an idex and store it's value. The key must be a string and the value could be of any type.

StringTrie

A Trie to store and search for strings.

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has 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.1 1,543 12/17/2017
1.0.0 1,206 12/17/2017