Radix.walk
You're seeing just the function
walk
, go back to Radix module for more information.
Specs
Invokes fun
on all (internal and leaf) nodes of the radix tree
using either
:inorder
, :preorder
or :postorder
traversal.
fun
should have the signatures:
Examples
Get all values in the tree.
iex> t = new([{<<1>>, 1}, {<<2>>, 2}, {<<3>>, 3}, {<<128>>, 128}])
iex> f = fn
...> (acc, {_bit, _left, _right}) -> acc
...> (acc, leaf) -> acc ++ Enum.map(leaf, fn {_k, v} -> v end)
...> end
iex> walk(t, [], f)
[1, 2, 3, 128]
Get all the keys in the tree
iex> t = new([{<<1>>, 1}, {<<2>>, 2}, {<<3>>, 3}, {<<128>>, 128}])
iex> f = fn
...> (acc, {_bit, _left, _right}) -> acc
...> (acc, leaf) -> acc ++ Enum.map(leaf, fn {k, _v} -> k end)
...> end
iex> walk(t, [], f)
[<<1>>, <<2>>, <<3>>, <<128>>]