autocomplete-trie-search
1.0.5
dotnet add package autocomplete-trie-search --version 1.0.5
NuGet\Install-Package autocomplete-trie-search -Version 1.0.5
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="autocomplete-trie-search" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add autocomplete-trie-search --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: autocomplete-trie-search, 1.0.5"
#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 autocomplete-trie-search as a Cake Addin
#addin nuget:?package=autocomplete-trie-search&version=1.0.5
// Install autocomplete-trie-search as a Cake Tool
#tool nuget:?package=autocomplete-trie-search&version=1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
autocomplete-trie-search
A trie data structure implementation for autocomplete search.
Implementation
using autocomplete_trie_search;
using autocomplete_trie_search.Interface;
using System.Diagnostics;
namespace autocomplete_trie_search_unit_test
{
public class Tests
{
private AutoCompleteTrieSearch search;
[SetUp]
public void Setup()
{
search = new AutoCompleteTrieSearch();
}
[Test]
public void InsertBySingleElement()
{
INodeValue node = new NodeValueOptions()
{
Text = "Some text",
Value = new {Id = 1, Text = "I am okay"},
Weight = 10
};
Assert.IsTrue(search.InsertOrUpdate(node));
}
[Test]
public void InsertByMultipleElement()
{
List<INodeValue> nodes = new List<INodeValue>();
for(int i = 0; i<=100000; i++)
{
INodeValue node = new NodeValueOptions()
{
Text = Guid.NewGuid().ToString(),
Value = new { Id = 1, Text = "I am okay" },
Weight = 10
};
nodes.Add(node);
}
Assert.IsTrue(search.InsertOrUpdate(nodes));
}
[Test]
public void Insert100000ElementTimeComplexity()
{
List<INodeValue> nodes = new List<INodeValue>();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
for (int i = 0; i <= 100000; i++)
{
INodeValue node = new NodeValueOptions()
{
Text = Guid.NewGuid().ToString(),
Value = new { Id = 1, Text = "I am okay" },
Weight = 10
};
nodes.Add(node);
}
search.InsertOrUpdate(nodes);
stopwatch.Stop();
Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, 12000);
}
[Test]
public void Insert10000ElementTimeComplexity()
{
List<INodeValue> nodes = new List<INodeValue>();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
for (int i = 0; i <= 10000; i++)
{
INodeValue node = new NodeValueOptions()
{
Text = Guid.NewGuid().ToString(),
Value = new { Id = 1, Text = "I am okay" },
Weight = 10
};
nodes.Add(node);
}
search.InsertOrUpdate(nodes);
stopwatch.Stop();
Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, 2000);
}
[Test]
public void NodeCountFor10000Element()
{
List<INodeValue> nodes = new List<INodeValue>();
for (int i = 0; i <= 100000; i++)
{
INodeValue node = new NodeValueOptions()
{
Text = Guid.NewGuid().ToString().Substring(0,16),
Value = new { Id = 1, Text = "I am okay" },
Weight = 10
};
nodes.Add(node);
}
search.InsertOrUpdate(nodes);
Assert.LessOrEqual(search.GetNodeCount(), 800000);
}
[Test]
public void MemoryUsageFor10000Element()
{
Process process = Process.GetCurrentProcess();
long startMemory = process.WorkingSet64;
List<INodeValue> nodes = new List<INodeValue>();
for (int i = 0; i <= 20000; i++)
{
INodeValue node = new NodeValueOptions()
{
Text = Guid.NewGuid().ToString().Substring(0, 16),
Value = new { Id = 1, Text = "I am okay" },
Weight = 10
};
nodes.Add(node);
}
search.InsertOrUpdate(nodes);
process = Process.GetCurrentProcess();
long endMemory = process.WorkingSet64;
long memoryUsed = endMemory - startMemory;
Console.WriteLine("Memory used: {0:N0} bytes", memoryUsed);
Assert.LessOrEqual(memoryUsed, 165 * 1024 * 1024);
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.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.