Last active
February 12, 2019 07:36
-
-
Save alirezameskin/a3852af6690ca7b295568a40a0183d06 to your computer and use it in GitHub Desktop.
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
object TrieApp extends App { | |
val trie = Trie[Int] | |
.insert("to", 7) | |
.insert("a", 15) | |
.insert("tea", 3) | |
.insert("ted", 4) | |
.insert("ten", 12) | |
.insert("i", 11) | |
.insert("in", 5) | |
.insert("inn", 9) | |
println(trie.search("ted")) // Some(4) | |
println(trie.search("ten")) // Some(12) | |
println(trie.search("invalid")) //None | |
val newTrie = trie | |
.delete("ted") | |
.delete("ten") | |
.delete("not existing") | |
println(newTrie.search("ted")) //None | |
println(newTrie.search("ten")) //None | |
println(newTrie.search("inn")) //Some(9) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment