Radix.update

You're seeing just the function update, go back to Radix module for more information.
Link to this function

update(tree, key, default, fun)

View Source

Specs

update(tree(), key(), value(), (value() -> value())) :: tree()

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}