Class: Gcntree

Gcntree(config)

new Gcntree(config)

N-ary (k-way) tree
Parameters:
Name Type Description
config Object configuration
Properties
Name Type Description
root Gcntree_node node to set as root
Source:

Namespaces

trans

Methods

(static) from_json(json) → {Gcntree}

Deserialize a Gcntree that was previously serialized using Gcntree.toJSON
Parameters:
Name Type Description
json string a serialized Gcntree
Source:
Returns:
Type
Gcntree

(static) from_json_doc(obj, trans) → {Gcntree}

Factory function to create a Gcntree from the JSON representation of a YAML document. Not to be confused with Gcntree.from_json
Parameters:
Name Type Description
obj Object a JSON object representing a YAML document
trans function transformer function - one of Gcntree.trans
Source:
Returns:
Type
Gcntree

dfs(pre, post, data) → {Array}

Depth first search
Parameters:
Name Type Description
pre Gcntree~dfs_cb preorder visitation callback
post Gcntree~dfs_cb postorder visitation callback
data Array this array will be returned upon termination, useful for accumulation, etc.
Source:
Returns:
the data array
Type
Array

get_node(node_num) → {Gcntree_node}

Fetch a node from this tree by node number as enumerated by Gcntree#dfs preorder traversal
Parameters:
Name Type Description
node_num number the node number
Source:
Returns:
Type
Gcntree_node

toJSON() → {string}

Serialize this Gcntree. This method serializes trees as linear arrays of Gcntree_node objects with null sentinels indicating "end of children"
Source:
See:
Returns:
the serialized tree
Type
string

Type Definitions

dfs_cb(node, data)

Depth first search visitation callback
Parameters:
Name Type Description
node Gcntree_node reference to the currently visited node
data Array reference to the data array
Source: