TreeLike

interface TreeLike<out T : TreeLike<T>>(source)

Represents a tree-like hierarchical structure, where each node has a parent and a collection of child nodes.

Report a problem

Parameters

T

The type parameter representing the node type, which must also implement TreeLike.

Properties

Link copied to clipboard
abstract val children: Iterable<T>
Link copied to clipboard
abstract val parent: T?

Functions

Link copied to clipboard
open fun descendants(): Sequence<T>

Returns a sequence of nodes from the current node and its descendants.

Link copied to clipboard
open fun isLeaf(): Boolean

Returns true if the current node has no children.

Link copied to clipboard
open fun isRoot(): Boolean

Returns true if the current node is a root node.

Link copied to clipboard
open fun lineage(): Sequence<T>

Returns a sequence of nodes from the current node up to the root.