Radix.update
You're seeing just the function
update
, go back to Radix module for more information.
Specs
Lookup given search key
in tree
and update the value of matched key with
the given function.
If key
has a longest prefix match in tree
then its value is passed to
fun
and its result is used as the updated value of the matching key. If
key
cannot be matched the {default
, key
}-pair is inserted in
the tree
.
Example
iex> t = new()
iex> t = update(t, <<1, 1, 1>>, 1, fn x -> x+1 end)
iex> t
{0, [{<<1, 1, 1>>, 1}], nil}
iex> t = update(t, <<1, 1, 1, 0>>, 1, fn x -> x+1 end)
iex> t
{0, [{<<1, 1, 1>>, 2}], nil}
iex> t = update(t, <<1, 1, 1, 255>>, 1, fn x -> x+1 end)
iex> t
{0, [{<<1, 1, 1>>, 3}], nil}