TreeNode

internal class TreeNode<T>(var name: String, val depth: Int, var data: T, val parent: TreeNode<T>? = null) : ReadonlyTreeNode<T>

Constructors

Link copied to clipboard
constructor(name: String, depth: Int, data: T, parent: TreeNode<T>? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val children: List<TreeNode<T>>
Link copied to clipboard
open override var data: T
Link copied to clipboard
open override val depth: Int
Link copied to clipboard
open override var name: String
Link copied to clipboard
open override val parent: TreeNode<T>?

Functions

Link copied to clipboard
fun addChild(childName: String, childData: T): TreeNode<T>
Link copied to clipboard
fun allChildren(enterCondition: (TreeNode<T>) -> Boolean = { true }, yieldCondition: (TreeNode<T>) -> Boolean = { true }): List<TreeNode<T>>

Traverses the tree in depth-first order and returns all nodes that satisfy yieldCondition. If enterCondition returns false for a node, its children are not traversed. By default, all nodes are traversed and all nodes are returned.

Link copied to clipboard
internal fun <T> TreeNode<T?>.allChildrenNotNull(): List<TreeNode<T>>
Link copied to clipboard
Link copied to clipboard
fun contains(childName: String): Boolean
Link copied to clipboard
open operator override fun get(childName: String): TreeNode<T>?
Link copied to clipboard
internal tailrec fun <T> ReadonlyTreeNode<T>.getAncestor(depth: Int): ReadonlyTreeNode<T>
Link copied to clipboard
fun getOrPut(childName: String, createData: () -> T): TreeNode<T>
Link copied to clipboard
internal fun <T> TreeNode<T?>.getOrPut(path: ColumnPath): TreeNode<T?>
internal fun <T> TreeNode<T>.getOrPut(path: ColumnPath, createData: (ColumnPath) -> T): TreeNode<T>
Link copied to clipboard
internal fun <T> TreeNode<T>.getOrPutEmpty(path: ColumnPath, emptyData: T): TreeNode<T>
Link copied to clipboard
open override fun getRoot(): TreeNode<T>
Link copied to clipboard
Link copied to clipboard
internal fun <T> TreeNode<T?>.put(path: ColumnPath, data: T): TreeNode<T?>
Link copied to clipboard
Link copied to clipboard
internal fun <T> TreeNode<T>.topmostChildren(yieldCondition: (TreeNode<T>) -> Boolean): List<TreeNode<T>>

Traverses all children in the tree in depth-first order and returns the top-most nodes that satisfy yieldCondition. This means that if a node satisfies yieldCondition, its children are not traversed, regardless of whether they satisfy yieldCondition or not.

Link copied to clipboard
internal fun <T> TreeNode<T>.topmostChildrenExcluding(excludeRoot: TreeNode<*>): List<TreeNode<T>>
Link copied to clipboard