mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2025-04-19 23:19:03 +02:00
child
function is now returning TreeNode
This commit is contained in:
parent
3c3d418aa2
commit
c320411a40
@ -15,7 +15,8 @@ interface ChildDeclarationInterface<T> {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @return New created TreeNode.
|
||||||
*/
|
*/
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
fun child(value: T, childDeclaration: ChildDeclaration<T>? = null)
|
fun child(value: T, childDeclaration: ChildDeclaration<T>? = null): TreeNode<T>
|
||||||
}
|
}
|
@ -27,11 +27,12 @@ open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>>, ChildDeclarationIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmSynthetic
|
@JvmSynthetic
|
||||||
override fun child(value: T, childDeclaration: ChildDeclaration<T>?) {
|
override fun child(value: T, childDeclaration: ChildDeclaration<T>?): TreeNode<T> {
|
||||||
val newChild = TreeNode(value)
|
val newChild = TreeNode(value)
|
||||||
if(childDeclaration != null)
|
if(childDeclaration != null)
|
||||||
newChild.childDeclaration()
|
newChild.childDeclaration()
|
||||||
_children.add(newChild)
|
_children.add(newChild)
|
||||||
|
return newChild
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,20 +139,4 @@ class TreeNodeTest {
|
|||||||
}
|
}
|
||||||
assertEquals(root.prettyString(), rootExt.prettyString())
|
assertEquals(root.prettyString(), rootExt.prettyString())
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
|
||||||
// fun getVisibleNodes() {
|
|
||||||
// val root = tree("World") {
|
|
||||||
// child("Level 1") {
|
|
||||||
// child("Level 2") {
|
|
||||||
// child("Level 3") {
|
|
||||||
// child("Level 4")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// print(root.prettyString())
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user