Iptrie.to_list

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

Specs

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

Returns all prefix,value-pairs from all available radix trees in trie.

Examples

iex> ipt = new()
...> |> put("1.1.1.0/24", 1)
...> |> put("2.2.2.0/24", 2)
...> |> put("acdc:1975::/32", 3)
...> |> put("acdc:2021::/32", 4)
iex>
iex> to_list(ipt)
[
  {%Pfx{bits: <<1, 1, 1>>, maxlen: 32}, 1},
  {%Pfx{bits: <<2, 2, 2>>, maxlen: 32}, 2},
  {%Pfx{bits: <<0xacdc::16, 0x1975::16>>, maxlen: 128}, 3},
  {%Pfx{bits: <<0xacdc::16, 0x2021::16>>, maxlen: 128}, 4}
]

Specs

to_list(t(), type()) :: [{prefix(), any()}]

Returns the prefix,value-pairs from the radix trees in trie for given type.

If the radix tree for type does not exist, an empty list is returned.

Examples

iex> ipt = new()
...> |> put("1.1.1.0/24", 1)
...> |> put("2.2.2.0/24", 2)
...> |> put("acdc:1975::/32", 3)
...> |> put("acdc:2021::/32", 4)
iex>
iex> to_list(ipt, 32)
[
  {%Pfx{bits: <<1, 1, 1>>, maxlen: 32}, 1},
  {%Pfx{bits: <<2, 2, 2>>, maxlen: 32}, 2}
]
iex> to_list(ipt, 128)
[
  {%Pfx{bits: <<0xacdc::16, 0x1975::16>>, maxlen: 128}, 3},
  {%Pfx{bits: <<0xacdc::16, 0x2021::16>>, maxlen: 128}, 4}
]
iex> to_list(ipt, 48)
[]