WIP new UI elem

This commit is contained in:
minjaesong
2018-12-08 23:10:48 +09:00
committed by Minjae Song
parent 20dfc95d0d
commit 11f7fa5c9a
9 changed files with 294 additions and 94 deletions

View File

@@ -0,0 +1,28 @@
package net.torvald.terrarum
import java.util.ArrayList
class QNDTreeNode<T>(var data: T? = null, var parent: QNDTreeNode<T>? = null) {
var children = ArrayList<QNDTreeNode<T>>()
private fun traverse1(node: QNDTreeNode<T>, action: (QNDTreeNode<T>, Int) -> Unit, depth: Int = 0) {
//if (node == null) return
action(node, depth)
node.children.forEach { traverse1(it, action, depth + 1) }
}
private fun traverse2(node: QNDTreeNode<T>, action: (QNDTreeNode<T>, Int) -> Unit, depth: Int = 0) {
//if (node == null) return
node.children.forEach { traverse2(it, action, depth + 1) }
action(node, depth)
}
fun traversePreorder(action: (QNDTreeNode<T>, Int) -> Unit) {
this.traverse1(this, action)
}
fun traversePostorder(action: (QNDTreeNode<T>, Int) -> Unit) {
this.traverse2(this, action)
}
}