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.
Frees memory allocated to units and then initializes member
variables with 0 and NULLs. Note that this does not free memory if
the array of units was set by darts_set_array.
Searches for keys which match a prefix of the
given string. If length is 0, key is handled as a zero-terminated string.
The values and the lengths of at most max_num_results matched keys are
stored in results. Returns the number of matched
keys. Note that the return value can be larger than max_num_results if
there are more than max_num_results matches. If you want to get all the
results, allocate more spaces and call this again.
node_pos works as well as in darts_exact_match_search.
Tests whether the given key exists or not, and
if it exists, its value and length are returned. Otherwise, the
value and the length of return value are set to -1 and 0 respectively.
Reads an array of units from the specified file. And if it goes
well, the old array will be freed and replaced with the new array read
from the file. offset specifies the number of bytes to be skipped before
reading an array. size specifies the number of bytes to be read from the
file. If the `size’ is 0, the whole file will be read.
Writes the array of units into the specified file. `offset’
specifies the number of bytes to be skipped before writing the array.
Returns 0 iff the operation succeeds. Otherwise, returns a non-zero value.
In Darts-clone, a dictionary is a deterministic finite-state automaton
(DFA) and this tests transitions on the DFA. The initial state is
node_pos and the function chooses transitions labeled key[key_pos],
key[key_pos + 1], … in order. If there is not a transition labeled
key[key_pos + i], the function terminates the transitions at that state and
returns -2. Otherwise, the function ends without a termination and returns
-1 or a nonnegative value, -1 indicates that the final state was not an
accept state. When a nonnegative value is returned, it is the value
associated with the final accept state. That is, the function returns the
value associated with the given key if it exists. Note that the function
updates node_pos and key_pos after each transition.