Iptrie.put

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

Specs

put(t(), [{prefix(), any()}]) :: t()

Populate the trie with a list of {prefix,value}-pairs.

This always uses an exact match for prefix, updating its value if it exists. Any errors are silently ignored as the trie is always returned.

Example

iex> ipt = new([{"1.1.1.0/24", 0}, {"1.1.1.1", 0}, {"1.1.1.1", "x"}])
iex>
iex> get(ipt, "1.1.1.1")
{"1.1.1.1", "x"}
Link to this function

put(trie, prefix, value)

View Source

Specs

put(t(), prefix(), any()) :: t()

Puts value under prefix in the trie.

This always uses an exact match for prefix, replacing its value if it exists. Any errors are silently ignored as the tree is always returned.

Example

iex> ipt = new()
...> |> put("1.1.1.0/24", 0)
...> |> put("1.1.1.1", 1)
...> |> put("1.1.1.1", "x")
iex>
iex> get(ipt, "1.1.1.1")
{"1.1.1.1", "x"}