darts_build

Function darts_build 

Source
pub unsafe extern "C" fn darts_build(
    darts: DartsT,
    num_keys: size_t,
    keys: *const *const DartsKeyType,
    lengths: *const size_t,
    values: *const DartsValueType,
    progress_func: Option<unsafe extern "C" fn(arg1: size_t, arg2: size_t) -> c_int>,
) -> c_int
Expand description

Constructs a dictionary from given key-value pairs. If lengths is NULL, keys is handled as an array of zero-terminated strings. If values is NULL, the index in keys is associated with each key, i.e. the ith key has (i - 1) as its value.

Note that the key-value pairs must be arranged in key order and the values must not be negative. Also, if there are duplicate keys, only the first pair will be stored in the resultant dictionary.

progress_func is a pointer to a callback function. If it is not NULL, it will be called in this function so that the caller can check the progress of dictionary construction.

The return value is 0, and it indicates the success of the operation. Otherwise, get error message from darts_error().

Uses another construction algorithm if values is not NULL. In this case, Darts-clone uses a Directed Acyclic Word Graph (DAWG) instead of a trie because a DAWG is likely to be more compact than a trie.