Radix.pop
You're seeing just the function
pop
, go back to Radix module for more information.
Specs
Removes the value associated with key
and returns the matched
key,value-pair and the new tree.
Options include:
default: value
, returned ifkey
could not be matched (defaults to nil)match: :lpm
, specifies a longest prefix match instead of an exact match
If given search key
was not matched, the tree is unchanged and the
key,value-pair will be the search key
and the default value.
Examples
# pop an existing element
iex> new([{<<0>>, 0}, {<<1>>, 1}, {<<2>>, 2}])
...> |> pop(<<1>>)
{
{<<1>>, 1},
{0, {6, [{<<0>>, 0}], [{<<2>>, 2}]}, nil}
}
# pop non-existing, using a default
iex> new([{<<0>>, 0}, {<<1>>, 1}, {<<2>>, 2}])
...> |> pop(<<3>>, default: :notfound)
{
{<<3>>, :notfound},
{0, {6, {7, [{<<0>>, 0}], [{<<1>>, 1}]}, [{<<2>>, 2}]}, nil}
}
# pop using longest prefix match
iex> new([{<<1, 1, 1>>, "1.1.1.0/24"}, {<<1, 1, 1, 1::1>>, "1.1.1.128/25"}])
...> |> pop(<<1, 1, 1, 255>>, match: :lpm)
{
{<<1, 1, 1, 1::1>>, "1.1.1.128/25"},
{0, [{<<1, 1, 1>>, "1.1.1.0/24"}], nil}
}