Learn R Programming

triebeard (version 0.3.0)

trie: Create a Trie

Description

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).

Usage

trie(keys, values)

Value

a `trie` object.

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.

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

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

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

Run the code above in your browser using DataLab