mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2025-07-01 15:27:58 +02:00
Renamed functions.
This commit is contained in:
@ -15,7 +15,7 @@ android {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.1.0"
|
||||
versionName "1.2.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
@ -5,17 +5,17 @@ interface ChildDeclarationInterface<T> {
|
||||
/**
|
||||
* This method is used to easily create child in node.
|
||||
* ```
|
||||
* val root = treeNode("World") {
|
||||
* treeNode("North America") {
|
||||
* treeNode("USA")
|
||||
* val root = tree("World") {
|
||||
* child("North America") {
|
||||
* child("USA")
|
||||
* }
|
||||
* treeNode("Europe") {
|
||||
* treeNode("Poland")
|
||||
* treeNode("Germany")
|
||||
* child("Europe") {
|
||||
* child("Poland")
|
||||
* child("Germany")
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@JvmSynthetic
|
||||
fun treeNode(value: T, childDeclaration: ChildDeclaration<T>? = null)
|
||||
fun child(value: T, childDeclaration: ChildDeclaration<T>? = null)
|
||||
}
|
@ -27,7 +27,7 @@ open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>>, ChildDeclarationIn
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
override fun treeNode(value: T, childDeclaration: ChildDeclaration<T>?) {
|
||||
override fun child(child: T, childDeclaration: ChildDeclaration<T>?) {
|
||||
val newChild = TreeNode(value)
|
||||
if(childDeclaration != null)
|
||||
newChild.childDeclaration()
|
||||
|
@ -5,13 +5,14 @@ typealias ChildDeclaration<T> = ChildDeclarationInterface<T>.() -> Unit
|
||||
/**
|
||||
* This method can be used to initialize new tree.
|
||||
* ```
|
||||
* val root = treeNode("World") { ... }
|
||||
* val root = tree("World") { ... }
|
||||
* ```
|
||||
* @see [ChildDeclarationInterface.treeNode]
|
||||
* @param root Root element of new tree.
|
||||
* @see [ChildDeclarationInterface.child]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
inline fun<reified T> treeNode(value: T, childDeclaration: ChildDeclaration<T>): TreeNode<T> {
|
||||
val treeNode = TreeNode(value)
|
||||
inline fun<reified T> tree(root: T, childDeclaration: ChildDeclaration<T>): TreeNode<T> {
|
||||
val treeNode = TreeNode(root)
|
||||
treeNode.childDeclaration()
|
||||
return treeNode
|
||||
}
|
Reference in New Issue
Block a user