package carleton.comp2601.historyviewer
class HNTree {
var hostComponent: String = ""
var hostSuffix: String = ""
var parent: HNTree = this
var children: MutableList<HNTree> = mutableListOf()
var treeLevel: Int = 0
var expanded: true
fun add(hostPrefix: String) {
var allComponents: List<String>
var component: String
var child: HNTree? = null
/* still have to deal with getting to the end */
allComponents = hostPrefix.split(".")
if (allComponents.last() == "") {
allComponents = allComponents.dropLast(1)
}
component = allComponents.last()
if (component == hostPrefix) {
return
}
for (c in this.children) {
if (c.hostComponent == component) {
child = c
break
}
}
if (child == null) {
child = HNTree()
child.parent = this
child.hostComponent = component
child.hostSuffix = "$component.$hostSuffix"
child.treeLevel++
children.add(child)
}
child.add(allComponents.dropLast(1).joinToString())
}
fun nextNodes(n: Int): List<HNTree> {
for (i in 0..n -1) {
}
}
}