Iptrie.pop

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

pop(trie, prefix, opts \\ [])

View Source

Specs

pop(t(), prefix(), keyword()) :: {{prefix(), any()}, t()}

Removes the value associated with prefix and returns the matched prefix,value-pair and the new Iptrie.

Options include:

  • default: value to return if prefix could not be matched (defaults to nil)
  • match: :lpm to match on longest prefix instead of an exact match

Examples

iex> t = new([{"1.1.1.0/24", 1}, {"1.1.1.99", 2}, {"acdc:1975::/32", 3}])
iex> {{"1.1.1.99", 2}, t2} = pop(t, "1.1.1.99")
iex> get(t2, "1.1.1.99")
nil

iex> t = new([{"1.1.1.0/24", 1}, {"1.1.1.99", 2}, {"acdc:1975::/32", 3}])
iex> # t is unchanged
iex> {{"1.1.1.33", :notfound}, ^t} = pop(t, "1.1.1.33", default: :notfound)

iex> t = new([{"1.1.1.0/24", 1}, {"1.1.1.99", 2}, {"acdc:1975::/32", 3}])
iex> # lpm match
iex> {{"1.1.1.0/24", 1}, t2} = pop(t, "1.1.1.33", match: :lpm)
iex> get(t2, "1.1.1.0/24")
nil