IEnumerableTrie 1.0.0

There is a newer version of this package available.
See the version list below for details.
Install-Package IEnumerableTrie -Version 1.0.0
dotnet add package IEnumerableTrie --version 1.0.0
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IEnumerableTrie, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.


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))

There are a few Simple implementations ready to be used:


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.


A Trie to store and search for strings.

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 928 12/17/2017
1.0.0 744 12/17/2017