Iptrie.split

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

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

View Source

Specs

split(
  t(),
  [prefix()],
  keyword()
) :: {t(), t()}

Splits trie into two Iptries using given list of prefixes.

Returns a new trie with prefix,value-pairs that were matched by given prefixes and the old trie with those pairs removed. If a prefix was not found in given trie it is ignored.

By default an exact match is used, specify match: :lpm to use longest prefix match instead.

Examples

iex> t = new([{"1.1.1.0/24", 1}, {"2.2.2.0/24", 2}, {"3.3.3.0/30", 3}])
iex> {t2, t3} = split(t, ["2.2.2.0/24", "3.3.3.0/30"])
iex> count(t2)
2
iex> get(t2, "2.2.2.0/24")
{"2.2.2.0/24", 2}
iex> get(t2, "3.3.3.0/30")
{"3.3.3.0/30", 3}
iex> count(t3)
1
iex> get(t3, "1.1.1.0/24")
{"1.1.1.0/24", 1}

# use longest prefix match
iex> t = new([{"1.1.1.0/24", 1}, {"2.2.2.0/24", 2}, {"3.3.3.0/30", 3}])
iex> {t4, t5} = split(t, ["2.2.2.2", "3.3.3.3"], match: :lpm)
iex> count(t4)
2
iex> get(t4, "2.2.2.0/24")
{"2.2.2.0/24", 2}
iex> get(t4, "3.3.3.0/30")
{"3.3.3.0/30", 3}
iex> count(t5)
1
iex> get(t5, "1.1.1.0/24")
{"1.1.1.0/24", 1}