Radix.lookup_and_update

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

lookup_and_update(tree, key, default \\ nil, fun)

View Source

Specs

lookup_and_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 is present in map then the existing value is passed to fun and its result is used as the updated value of key. If key is not present in map, default is inserted as the value of key. The default value will not be passed through the update function.

Examples

iex> t = new()
iex> t = lookup_and_update(t, <<1, 1, 1>>, 1, fn x -> x+1 end)
iex> t
{0, [{<<1, 1, 1>>, 1}], nil}
iex> t = lookup_and_update(t, <<1, 1, 1>>, 1, fn x -> x+1 end)
iex> t
{0, [{<<1, 1, 1>>, 2}], nil}
iex> t = lookup_and_update(t, <<1, 1, 1, 1>>, 1, fn x -> x+1 end)
iex> t
{0, [{<<1, 1, 1>>, 3}], nil}