TreeNode

data class TreeNode<T> : Iterable<TreeNode<T>>

Constructors

Link copied to clipboard
fun <T> TreeNode(value: T)

Functions

Link copied to clipboard
fun addChild(child: T)

Add new child to current node or root.

Link copied to clipboard
fun child(child: T): TreeNode<T>

Add new child to current node or root.

Link copied to clipboard
fun clear()

Remove all children from root and every node in tree.

Link copied to clipboard
fun depth(): Int

Distance is the number of edges along the shortest path between two nodes.

Link copied to clipboard
open fun forEach(p0: Consumer<in TreeNode<T>>)
Link copied to clipboard
fun height(): Int
Link copied to clipboard
open operator override fun iterator(): Iterator<TreeNode<T>>

Tree is iterated by using `Pre-order Traversal Algorithm"

Link copied to clipboard
fun nodeCount(): Int

This function go through tree and counts children. Root element is not counted.

Link copied to clipboard
fun prettyString(onPrint: (T) -> String? = null): String
Link copied to clipboard

Removes a single instance of the specified node from this tree, if it is present.

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard

A group of nodes with the same parent.

Link copied to clipboard

The converse notion of a child, an immediate ancestor.

Link copied to clipboard
Link copied to clipboard
val value: T

Extensions

Link copied to clipboard
fun <T> TreeNode<T>.node(value: T, builder: TreeNode<T>.() -> TreeNode<T>? = null): TreeNode<T>