mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2025-09-14 22:44:23 +02:00
Compare commits
3 Commits
develop
...
5eaf027dba
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5eaf027dba | ||
![]() |
04c3728fcd | ||
![]() |
d34050e9af |
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
2
.github/workflows/publishSnapshot.yml
vendored
2
.github/workflows/publishSnapshot.yml
vendored
@@ -2,7 +2,7 @@ name: Publish Snapshot
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, '14-**']
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@@ -9,7 +9,7 @@ plugins {
|
||||
|
||||
val PUBLISH_GROUP_ID = "com.github.adriankuta"
|
||||
val PUBLISH_ARTIFACT_ID = "tree-structure"
|
||||
val PUBLISH_VERSION = "3.0.1"
|
||||
val PUBLISH_VERSION = "3.0.2"
|
||||
|
||||
val secretFile = File(rootProject.rootDir, "local.properties")
|
||||
if (secretFile.exists()) {
|
||||
|
@@ -8,7 +8,10 @@ import com.github.adriankuta.datastructure.tree.iterators.TreeNodeIterators
|
||||
import com.github.adriankuta.datastructure.tree.iterators.TreeNodeIterators.*
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>>, ChildDeclarationInterface<T> {
|
||||
/**
|
||||
* @param treeIterator Choose one of available iterators from [TreeNodeIterators]
|
||||
*/
|
||||
open class TreeNode<T>(val value: T, var treeIterator: TreeNodeIterators = PreOrder) : Iterable<TreeNode<T>>, ChildDeclarationInterface<T> {
|
||||
|
||||
private var _parent: TreeNode<T>? = null
|
||||
|
||||
@@ -33,11 +36,6 @@ open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>>, ChildDeclarationIn
|
||||
val isRoot: Boolean
|
||||
get() = _parent == null
|
||||
|
||||
/**
|
||||
* Choose one of available iterators from [TreeNodeIterators]
|
||||
*/
|
||||
var defaultIterator: TreeNodeIterators = PreOrder
|
||||
|
||||
/**
|
||||
* Add new child to current node or root.
|
||||
*
|
||||
@@ -166,9 +164,9 @@ open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>>, ChildDeclarationIn
|
||||
}
|
||||
|
||||
/**
|
||||
* You can change default iterator by changing [defaultIterator] property.
|
||||
* You can change default iterator by changing [treeIterator] property.
|
||||
*/
|
||||
override fun iterator(): Iterator<TreeNode<T>> = when (defaultIterator) {
|
||||
override fun iterator(): Iterator<TreeNode<T>> = when (treeIterator) {
|
||||
PreOrder -> PreOrderTreeIterator(this)
|
||||
PostOrder -> PostOrderTreeIterator(this)
|
||||
LevelOrder -> LevelOrderTreeIterator(this)
|
||||
|
@@ -19,8 +19,7 @@ inline fun <reified T> tree(
|
||||
defaultIterator: TreeNodeIterators = TreeNodeIterators.PreOrder,
|
||||
childDeclaration: ChildDeclaration<T>
|
||||
): TreeNode<T> {
|
||||
val treeNode = TreeNode(root)
|
||||
treeNode.defaultIterator = defaultIterator
|
||||
val treeNode = TreeNode(root, defaultIterator)
|
||||
treeNode.childDeclaration()
|
||||
return treeNode
|
||||
}
|
Reference in New Issue
Block a user