TreeNode

open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>> , ChildDeclarationInterface<T>

Original library: https://github.com/AdrianKuta/Tree-Data-Structure

Constructors

Link copied to clipboard
constructor(value: T)

Properties

Link copied to clipboard

A group of nodes with the same parent.

Link copied to clipboard

Choose one of available iterators from TreeNodeIterators

Link copied to clipboard
val depth: Int

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

Link copied to clipboard
val height: Int
Link copied to clipboard

Checks whether the current tree node is the root of the tree

Link copied to clipboard

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

Link copied to clipboard

The converse notion of a child, an immediate ancestor.

Link copied to clipboard

The root of the tree.

Link copied to clipboard
val value: T

Functions

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

Add new child to current node or root.

Link copied to clipboard
open override fun child(value: T, childDeclaration: ChildDeclaration<T>?): TreeNode<T>

This method is used to easily create child in node.

Link copied to clipboard
fun clear()

Remove all children from root and every node in tree.

Link copied to clipboard
inline fun <T> Iterable<T>.eighth(): T

Returns eighth element.

Link copied to clipboard
inline fun <T> Iterable<T>.eighthOrNull(): T?
Link copied to clipboard
inline fun <T> Iterable<T>.fifth(): T

Returns fifth element.

Link copied to clipboard
inline fun <T> Iterable<T>.fifthOrNull(): T?
Link copied to clipboard
inline fun <T> Iterable<T>.forth(): T

Returns forth element.

Link copied to clipboard
inline fun <T> Iterable<T>.forthOrNull(): T?
Link copied to clipboard
open operator override fun iterator(): Iterator<TreeNode<T>>

You can change default iterator by changing defaultIterator property.

Link copied to clipboard
inline fun <T> Iterable<T>.ninth(): T

Returns ninth element.

Link copied to clipboard
inline fun <T> Iterable<T>.ninthOrNull(): T?
Link copied to clipboard
fun path(descendant: TreeNode<T>): List<TreeNode<T>>

Returns the collection of nodes, which connect the current node with its descendants

Link copied to clipboard
inline fun <T> Iterable<T>.penultimate(): T

Returns penultimate element.

Link copied to clipboard
inline fun <T> Iterable<T>.penultimateOrNull(): T?
Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
inline fun <T> Iterable<T>.second(): T

Returns second element.

Link copied to clipboard
inline fun <T> Iterable<T>.secondOrNull(): T?
Link copied to clipboard
inline fun <T> Iterable<T>.seventh(): T

Returns seventh element.

Link copied to clipboard
inline fun <T> Iterable<T>.seventhOrNull(): T?
Link copied to clipboard
inline fun <T> Iterable<T>.sixth(): T

Returns sixth element.

Link copied to clipboard
inline fun <T> Iterable<T>.sixthOrNull(): T?
Link copied to clipboard
inline fun <T> Iterable<T>.tenth(): T

Returns tenth element.

Link copied to clipboard
inline fun <T> Iterable<T>.tenthOrNull(): T?
Link copied to clipboard
inline fun <T> Iterable<T>.third(): T

Returns third element.

Link copied to clipboard
inline fun <T> Iterable<T>.thirdOrNull(): T?
Link copied to clipboard
open override fun toString(): String