graphqexl v0.1.0-alpha-rc.24 Treex.Tree
Primarily a struct for representing tree data to be processed with the Tree.Traverse
module.
Also includes implementations necessary for the Enumerable
protocol and conversion functions
to/from ordinary Map.t/0
representations of the same data.
One import note is the notion of a "virtual root." In order to represent arbitrary maps, any map
that has multiple top-level keys (i.e. has multiple roots and is a graph, not a tree) will be
converted to a tree by inserting a root node whose value defaults to :root
and can be specified
as the second parameter to Treex.Tree.from_map/2
.
Link to this section Summary
Functions
Counts the number of nodes in the given tree.
Convert the given map into a Treex.Tree.t/0
. If the given map has more than one top-level key,
the optional root
parameter specifies what value to give a virtual root node that will be
inserted at the top of the key and contain the given map
's top-level keys as children.
Checks whether the given node is a leaf node or not.
List the leaf nodes of the given Treex.Tree.t/0
Checks whether the given element is a member of the tree at any depth, performed breadth-first.
Reduces the given tree into the given accumulator by invoking the given Treex.Tree.reducer/0
function on each node, traversed breadth-first. The return is tagged tuple following the
Enumerable
protocol.
Generates a function that contiguously slices the given tree. See Enumerable.slice/1
Link to this section Types
result()
result() :: {:done, term()} | {:halted, term()} | {:suspended, term(), continuation()}
Link to this section Functions
Counts the number of nodes in the given tree.
Returns: t:integer
Convert the given map into a Treex.Tree.t/0
. If the given map has more than one top-level key,
the optional root
parameter specifies what value to give a virtual root node that will be
inserted at the top of the key and contain the given map
's top-level keys as children.
Returns: Treex.Tree.t/0
Checks whether the given node is a leaf node or not.
Returns: boolean/0
List the leaf nodes of the given Treex.Tree.t/0
Returns: [t:Treex.Tree.t/0]
Checks whether the given element is a member of the tree at any depth, performed breadth-first.
Returns: t:boolean
Reduces the given tree into the given accumulator by invoking the given Treex.Tree.reducer/0
function on each node, traversed breadth-first. The return is tagged tuple following the
Enumerable
protocol.
Returns: Treex.Tree.acc/0
(where term
is the same type as the acc
parameter)
slice(tree)
(since 0.1.0)slice(t()) :: {:ok, size(), slicing_fun()} | {:error, module()}
Generates a function that contiguously slices the given tree. See Enumerable.slice/1
Returns
{:ok, t:non_neg_integer/0, t:Treex.Tree.slicing_fun/0}
when successful
{:error, t:module/0}
when there is an error