Node

class Node<T, L>

Properties

Link copied to clipboard
var children: List<Node<T, L>>

Child nodes. If this is a leaf, then this list is empty.

Link copied to clipboard
val data: T

Data associated with this node.

Link copied to clipboard
val <T, L> Node<T, L>.depth: Int

Number of parents before hitting the root Node. If this is the root, then this is 0.

Link copied to clipboard
val <T, L> Node<T, L>.height: Int

Maximum number of children before hitting a leaf Node. If this is a leaf, then this is 0.

Link copied to clipboard
val <T, L> Node<T, L>.isLeaf: Boolean

Returns true if this node has no children.

Link copied to clipboard
var layout: L

Layout value. Null when initially created, but can be changed by using a tree-map or similar.

Link copied to clipboard
val parent: Node<T, L>? = null

The parent node, if any.

Functions

Link copied to clipboard
fun <T, L> Node<T, L>.ancestors(): Sequence<Node<T, L>>

Returns ancestor nodes, starting with this and then following the Node.parent chain.

Link copied to clipboard
fun <T, L> Node<T, L>.count(): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.each(crossinline action: (Node<T, L>) -> Unit): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.eachAfter(crossinline action: (Node<T, L>) -> Unit): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.eachAfterIndexed(crossinline action: (Int, Node<T, L>) -> Unit): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.eachBefore(crossinline action: (Node<T, L>) -> Unit): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.eachBeforeIndexed(crossinline action: (Int, Node<T, L>) -> Unit): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.eachIndexed(crossinline action: (Int, Node<T, L>) -> Unit): Node<T, L>
Link copied to clipboard
fun <T> Node<T, *>.layoutWith(treemap: Treemap<T>): Node<T, Tile>
Link copied to clipboard
fun <T, L> Node<T?, L>.removeHierarchy(): Sequence<Pair<T, L>>

Returns a breadth-first traversal of nodes, removing those with null data, and pairing the data to the layout.

Link copied to clipboard
fun <T, L> Node<T, L>.sort(comparator: Comparator<T>): Node<T, L>
Link copied to clipboard
inline fun <T, L> Node<T, L>.sum(crossinline value: (T) -> Float): Node<T, L>
Link copied to clipboard

Returns descendant nodes, starting with this and then following the Node.children chain in a breadth-first traversal.

Link copied to clipboard

Returns descendant nodes, starting with the Node.children chain in a depth-first traversal, and ending with this.

Link copied to clipboard

Returns descendant nodes, starting with this and then following the Node.children chain in a depth-first traversal.