mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2026-06-20 03:10:14 +02:00
Set the correct file structure to maintain backward compatibility. (#18)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.github.adriankuta.datastructure.tree
|
||||
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
typealias ChildDeclaration<T> = ChildDeclarationInterface<T>.() -> Unit
|
||||
|
||||
/**
|
||||
* This method can be used to initialize new tree.
|
||||
* ```
|
||||
* val root = tree("World") { ... }
|
||||
* ```
|
||||
* @param root Root element of new tree.
|
||||
* @see [ChildDeclarationInterface.child]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
inline fun <reified T> tree(
|
||||
root: T,
|
||||
defaultIterator: TreeNodeIterators = TreeNodeIterators.PreOrder,
|
||||
childDeclaration: ChildDeclaration<T>
|
||||
): TreeNode<T> {
|
||||
val treeNode = TreeNode(root)
|
||||
treeNode.defaultIterator = defaultIterator
|
||||
treeNode.childDeclaration()
|
||||
return treeNode
|
||||
}
|
||||
Reference in New Issue
Block a user