Tree

class Tree<T>

Set T to the type of attributes that you want to attach to a node For example: TreeNode has its attributes in List

Constructors

Link copied to clipboard
constructor()
constructor(root: TreeNode<T>)
constructor(treeName: String)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Get the node located at the current cursor

Link copied to clipboard
Link copied to clipboard

The root cannot be reassigned from outside the lib, but its properties can be changed (besides treeRef)

Link copied to clipboard

Functions

Link copied to clipboard
fun appendEmptyNamedToPaths(vararg namesPathPair: Pair<List<String>, List<Int>>): Int
Link copied to clipboard
fun appendEmptyNamedToPathsStrict(vararg namesPathPair: Pair<List<String>, List<Int>>): Boolean
Link copied to clipboard
fun appendNode(node: TreeNode<T>, vararg path: Int): Boolean

Append a node to a path from root

Link copied to clipboard
fun appendNodes(nodes: NodeList<T>, vararg path: Int): Boolean
Link copied to clipboard
fun checkPath(vararg path: Int): Int
fun checkPath(path: List<Int>): Int

Check if the path starting from root corresponds to a node

Link copied to clipboard
fun clone(): Tree<T>

Use to make an independent instance of this tree (deep copy)

Link copied to clipboard
fun cursorAppendEmptyNodes(vararg names: String): Tree<T>

Append empty named nodes to the node at the cursor

Link copied to clipboard
fun cursorAppendNode(name: String, attributes: List<T> = listOf()): Tree<T>

Append a node to the node at the cursor

Link copied to clipboard

Append nodes to the node at the cursor

Link copied to clipboard

Check if able to move the cursor up, up to n times.

Link copied to clipboard
Link copied to clipboard

Move your current position to parent node, if no parent exists, remain at the same place

Move the cursor up n times, stop when the

Link copied to clipboard
fun cursorSet(vararg path: Int): Tree<T>

Update your current position to a route from root, if no such path, remain at the same place

Link copied to clipboard
fun cursorSetRelative(vararg path: Int): Tree<T>

Set cursor relatively from current position. Remain at the same place if the path does not exist.

Link copied to clipboard
fun cursorSetWithResult(vararg path: Int): Int

Update your current position to a route from root, if no such path, remain at the same place

Link copied to clipboard

Get all leaves (nodes that have no children) from this tree

Link copied to clipboard

Get all nodes in the tree. The nodes in the list are sorted deep to shallow and right to left

Link copied to clipboard
fun getNodeOrNull(vararg path: Int): TreeNode<T>?

Get TreeNode at the certain path from root.

Link copied to clipboard
fun <T> Tree<T>.getStringPath(vararg path: Int): String

Get String representation of a path from the tree root.

Link copied to clipboard
fun isValidPath(vararg path: Int): Boolean

Check if this path from root is valid.

Link copied to clipboard

Prints out all leaves, each shifted by 20 * depth

Link copied to clipboard
fun setRootAttributes(attributes: List<T>): Tree<T>

Made for convenience and chaining. Direct tree.root.attributes = someList() is still possible.

Link copied to clipboard
fun setRootName(name: String): Tree<T>

Made for convenience and chaining. Direct tree.root.name = "someName" is still possible.

Link copied to clipboard

Get a visualization of the whole tree.