Tree

class Tree<Node : TreeNode<Node>, out RootNode : Node>(root: RootNode)

Computes and stores parent/child/sibling relations in a tree structure.

This class is a simplified version of Kiama's tree relations. Refer to the sections on Attribute Grammars and Relations. in Kiama's user manual for more information.

Parameters

Node

The type of nodes in the tree.

RootNode

The type of the root node of the tree.

root

The root node of the tree.

Constructors

Tree
Link copied to clipboard
fun <out RootNode : Node> Tree(root: RootNode)

Functions

childIndex
Link copied to clipboard
fun childIndex(node: Node): Int

Returns the index of node in its parent's children list.

nextSibling
Link copied to clipboard
fun nextSibling(node: Node): Node?

Returns the node that occurs just after node in its parent's children list, or null if node is the root or node is its parent's last child.

parent
Link copied to clipboard
fun parent(node: Node): Node?

Returns the parent of node, or null if node is the root.

previousSibling
Link copied to clipboard
fun previousSibling(node: Node): Node?

Returns the node that occurs just before node in its parent's children list, or null if node is the root or node is its parent's first child.

Properties

root
Link copied to clipboard
val root: RootNode