OrderedNaryTree (ordered_nary_tree v0.0.2)

A struct based implementation of a pure Elixir ordered n-ary tree

Link to this section Summary

Link to this section Types

@type t() :: %OrderedNaryTree{root: tree_node() | nil}
@type tree_node() :: OrderedNaryTree.Node.t()
Link to this type

tree_node_id()

@type tree_node_id() :: OrderedNaryTree.Node.id()

Link to this section Functions

Link to this function

add_child(tree, child_node)

@spec add_child(t(), tree_node()) :: {:ok, t()} | {:error, :empty_root}
Link to this function

add_child(tree, parent_node_id, child_node)

@spec add_child(t(), tree_node_id(), tree_node()) ::
  {:ok, t()} | {:error, :empty_root | :not_found}
@spec children(t()) :: {:ok, [tree_node()]} | {:error, :empty_root}
Link to this function

children(tree, node_id)

@spec children(t(), tree_node_id()) ::
  {:ok, [tree_node()]} | {:error, :empty_root | :not_found}
Link to this function

new(root \\ nil)

@spec new(tree_node() | nil) :: t()
@spec root(t()) :: {:ok, tree_node()} | {:error, :empty_root}