create_trie creates a trie (a key-value store optimised for matching) out of a provided character vector of keys, and a numeric, character, logical or integer vector of values (both the same length).

trie(keys, values)

Arguments

keys

a character vector containing the keys for the trie.

values

an atomic vector of any type, containing the values to pair with keys. Must be the same length as keys.

Value

a `trie` object.

See also

trie_add and trie_remove for adding to and removing from tries after their creation, and longest_match and other match functions for matching values against the keys of a created trie.

Examples

# An integer trie
int_trie <- trie(keys = "foo", values = 1)

# A string trie
str_trie <- trie(keys = "foo", values = "bar")