trie-typescript
v0.1.0
Published
A simple Trie data structure for optimized for lowercased latin alphanumeric strings. Optimization was done based on the following assumption:
Downloads
5
Readme
AlphaNumericTrie
A simple Trie data structure for optimized for lowercased latin alphanumeric strings. Optimization was done based on the following assumption:
- Lookup keys consists of alphabetical characters.
- Each Node in the trie holds an array of 36 cells for optimal lookup.
- 26 first cells are for lowercased alphabetical characters and the rest 10 for numeric.
- If a non supported character is inserted (e.g.
≈
,\
etc.), it is skipped.
Use
Install via npm:
npm i trie-typescript
or via yarn:
yarn add trie-typescript
JS usage example:
import { AlphaNumericTrie } from "trie-typescript";
const alphaNumericTrie = new AlphaNumericTrie();
alphaNumericTrie.add("foo123", { myVal: "bar" });
alphaNumericTrie.has("foo123"); // true
alphaNumericTrie.get("foo123"); // {myVal: "bar"}
alphaNumericTrie.add("Foo!!!", { myVal: "!!!bar" });
alphaNumericTrie.has("Foo!!!"); // false
alphaNumericTrie.get("foo"); // {myVal: "!!!bar"}
Feel free to reach out for feedback.