Iptrie.take

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

take(trie, prefixes, opts \\ [])

View Source

Specs

take(
  t(),
  [prefix()],
  keyword()
) :: t()

Returns a new Iptrie containing only given prefixes that were found in trie.

If a given prefix does not exist, it is ignored. Optionally specifiy match: :lpm to use a longest prefix match instead of exact, which is the default.

Examples

iex> t = new([{"1.1.1.0/24", 1}, {"2.2.2.0/24", 2}, {"acdc::/16", 3}])
iex> t2 = take(t, ["1.1.1.0/24", "acdc::/16"])
iex> count(t2)
2
iex> get(t2, "1.1.1.0/24")
{"1.1.1.0/24", 1}
iex> get(t2, "acdc::/16")
{"acdc:0:0:0:0:0:0:0/16", 3}

# use longest match
iex> t = new([{"1.1.1.0/24", 1}, {"2.2.2.0/24", 2}, {"acdc::/16", 3}])
iex> t3 = take(t, ["1.1.1.1", "acdc:1975::1"], match: :lpm)
iex> count(t3)
2
iex> get(t3, "1.1.1.0/24")
{"1.1.1.0/24", 1}
iex> get(t3, "acdc::/16")
{"acdc:0:0:0:0:0:0:0/16", 3}

# ignore missing prefixes
iex> t = new([{"1.1.1.0/24", 1}, {"2.2.2.0/24", 2}, {"acdc::/16", 3}])
iex> t4 = take(t, ["1.1.1.1", "3.3.3.3"], match: :lpm)
iex> count(t4)
1
iex> get(t4, "1.1.1.0/24")
{"1.1.1.0/24", 1}