Appearance
Tree
Inherits: Class
Methods
ChildrenIterator
lua
function Tree:ChildrenIterator(node)
-> fun():number, table, numberIterates over all the children of a node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node |
Returns:
| Type | Description |
|---|---|
fun():number | Iterator with fields: child |
table | |
number |
DepthFirstIterator
lua
function Tree:DepthFirstIterator(rootNode)
-> fun():number, tableIterates over the tree in depth-first order.
Parameters:
| Name | Type | Description |
|---|---|---|
rootNode | number | The rootNode to iterate from (defaults to the tree's root node) |
Returns:
| Type | Description |
|---|---|
fun():number | Iterator with fields: node |
table |
Dump
lua
function Tree:Dump(rootNode)Prints out the tree for debugging.
Parameters:
| Name | Type | Description |
|---|---|---|
rootNode | number | The root node to dump from |
GetChildren
lua
function Tree:GetChildren(node)
-> ...numberGets all the children of a node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node |
Returns:
| Type | Description |
|---|---|
...number |
GetData
lua
function Tree:GetData(node, fieldName)
-> ...anyGets the data stored for the specified node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node |
fieldName | string | The name of the field to get |
Returns:
| Type | Description |
|---|---|
...any |
GetDepth
lua
function Tree:GetDepth(node)
-> numberGets the depth of a node in the tree.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number |
Returns:
| Type | Description |
|---|---|
number |
GetNumChildren
lua
function Tree:GetNumChildren(node)
-> numberGets the number of children.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node |
Returns:
| Type | Description |
|---|---|
number |
GetParent
lua
function Tree:GetParent(node)
-> number?Gets the parent node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number |
Returns:
| Type | Description |
|---|---|
number? |
GetRoot
lua
function Tree:GetRoot()
-> numberGets the root node.
Returns:
| Type | Description |
|---|---|
number |
Insert
lua
function Tree:Insert(parent, ...)
-> numberInserts a node into the tree
Parameters:
| Name | Type | Description |
|---|---|---|
parent | number | The parent node |
... | any | The data fields for the node |
Returns:
| Type | Description |
|---|---|
number |
MoveUp
lua
function Tree:MoveUp(node)Moves a node up in the tree, replacing its parent.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node to move up |
RemoveAllChildren
lua
function Tree:RemoveAllChildren(node)Removes all children for a given node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number |
SetChildren
lua
function Tree:SetChildren(node, ...)Sets the children for a given node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node |
... | number | The new children |
SetData
lua
function Tree:SetData(node, fieldName, value)Sets a data field for a node.
Parameters:
| Name | Type | Description |
|---|---|---|
node | number | The node |
fieldName | string | The name of the field to set |
value | any | The data field value |
Wipe
lua
function Tree:Wipe()Wipes the tree.
_MoveHelper
lua
function Tree:_MoveHelper(newParent, oldParent, node)Parameters:
| Name | Type | Description |
|---|---|---|
newParent | `` | |
oldParent | `` | |
node | `` |
_Remove
lua
function Tree:_Remove(node)Parameters:
| Name | Type | Description |
|---|---|---|
node | `` |
Functions
Create
lua
function Tree.Create(...)
-> TreeCreates a new tree object.
Parameters:
| Name | Type | Description |
|---|---|---|
... | string | The data field names, in order |
Returns:
| Type | Description |
|---|---|
Tree |