key_traverse: Traverse the trie to a particular node by full key name.

Description Usage Arguments Value Examples

View source: R/trie.R

Description

Each node's formal name is a single character. You can traverse to the node of a key in the trie by splitting a key into characters and then traverseing from parent to child node. This is really just a helper function.

Usage

1
key_traverse(key, trie)

Arguments

key

the key to search for

trie

the trie to search for

Value

the trie node that corresponds to the key

Examples

1
2
3
4
5
6
test <- c("a", "ab", "bab", "bc", "bca", "c", "caa", "abc")
values <- c("foo", "bar", "foo", "bar", "foo", "bar", "foo", "bar")
example_trie <- trie_create(test, value = values)
key_traverse("c", example_trie)
key_traverse("ca", example_trie)
key_traverse("caa", example_trie)

lmkirvan/textTries documentation built on May 25, 2019, 9:32 p.m.