Last active
April 30, 2021 06:03
-
-
Save shamalroy/0feb2a7d881b67c32c9f to your computer and use it in GitHub Desktop.
Patricia Trie Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import org.apache.commons.collections4.Trie; | |
import org.apache.commons.collections4.trie.PatriciaTrie; | |
... | |
... | |
Map<String, BookInfo> library = new LinkedHashMap<>(); | |
/* Load your regualr map with data */ | |
library.put("To Kill a Mockingbird", new BookInfo("Harper Lee", "978-0061120084")); | |
libraby.put("Pride and Prejudice", new BookInfo("Jane Austen", "978-0679783268")); | |
libraby.put("To Kill A Warlock", new BookInfo("H.P. Mallory", "978-xxxxxxxx")); | |
libraby.put("To Kill For", new BookInfo("A.J. Carella", "978-xxxxxxxx")); | |
libraby.put("To Kill For", new BookInfo("A.J. Carella", "978-xxxxxxxx")); | |
... | |
... | |
/* PatriciaTrie map*/ | |
public static Trie<String, BookInfo> librabyTrie = new PatriciaTrie<>(libraby); | |
/* Subset of data based on your query string "To Kill" */ | |
SortedMap<String, BookInfo> entries = WordList.wordMapTrie.prefixMap("To Kill"); | |
... | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spelling - libraby-> library