Release 4.1.0: structural mutations, query algorithms, customizable prettyString, immutable module
Some checks failed
Test / JVM / JS / Wasm / Native + API check (push) Has been cancelled
Test / iOS (push) Has been cancelled

This commit is contained in:
2026-06-07 23:30:48 +02:00
parent 0b8429c859
commit f60a5c4a86
3 changed files with 28 additions and 8 deletions

View File

@@ -6,6 +6,8 @@ All notable changes to this project are documented here. The format is based on
## [Unreleased]
## [4.1.0] - 2026-06-07
### Added
- Structural mutation helpers on `TreeNode`: `insertChild`, `removeChildAt`, `replaceChild`,
`moveChild`, `addChildren`, and `sortChildren`.
@@ -89,7 +91,8 @@ A breaking release that cleans up the core API and enforces an explicit public s
## [3.1.3]
- iOS targets and Maven Central (Sonatype Central Portal) publishing.
[Unreleased]: https://github.com/AdrianKuta/Tree-Data-Structure/compare/v4.0.0...HEAD
[Unreleased]: https://github.com/AdrianKuta/Tree-Data-Structure/compare/v4.1.0...HEAD
[4.1.0]: https://github.com/AdrianKuta/Tree-Data-Structure/compare/v4.0.0...v4.1.0
[4.0.0]: https://github.com/AdrianKuta/Tree-Data-Structure/compare/v3.4.0...v4.0.0
[3.4.0]: https://github.com/AdrianKuta/Tree-Data-Structure/compare/v3.1.5...v3.4.0
[3.1.5]: https://github.com/AdrianKuta/Tree-Data-Structure/compare/v3.1.3...v3.1.5

View File

@@ -30,14 +30,14 @@ Gradle (Kotlin DSL):
```kotlin
// commonMain for KMP projects, or any sourceSet/module where you need it
dependencies {
implementation("com.github.adriankuta:tree-structure:4.0.0") // latest version is on the badge above
implementation("com.github.adriankuta:tree-structure:4.1.0") // latest version is on the badge above
}
```
Gradle (Groovy):
```groovy
dependencies {
implementation "com.github.adriankuta:tree-structure:4.0.0"
implementation "com.github.adriankuta:tree-structure:4.1.0"
}
```
@@ -46,7 +46,7 @@ Maven:
<dependency>
<groupId>com.github.adriankuta</groupId>
<artifactId>tree-structure</artifactId>
<version>4.0.0</version>
<version>4.1.0</version>
</dependency>
```
@@ -160,7 +160,7 @@ that depends on the core.
`@Serializable` directly. Convert to and from the acyclic `TreeNodeDto` instead.
```kotlin
implementation("com.github.adriankuta:tree-structure-serialization:4.0.0")
implementation("com.github.adriankuta:tree-structure-serialization:4.1.0")
```
```kotlin
val json = Json.encodeToString(root.toDto())
@@ -172,7 +172,7 @@ val restored = Json.decodeFromString<TreeNodeDto<String>>(json).toTreeNode()
Traverse a tree as a cold `Flow`, which is handy inside coroutine and `ViewModel` pipelines.
```kotlin
implementation("com.github.adriankuta:tree-structure-coroutines:4.0.0")
implementation("com.github.adriankuta:tree-structure-coroutines:4.1.0")
```
```kotlin
root.preOrderFlow().collect { println(it.value) }
@@ -185,7 +185,7 @@ A `LazyTree` composable for Compose Multiplatform (JVM/desktop, iOS, Wasm). Only
are composed, and you decide how each node looks:
```kotlin
implementation("com.github.adriankuta:tree-structure-compose:4.0.0")
implementation("com.github.adriankuta:tree-structure-compose:4.1.0")
```
```kotlin
LazyTree(root) { node, depth, expanded, toggle ->
@@ -196,6 +196,23 @@ LazyTree(root) { node, depth, expanded, toggle ->
}
```
### Immutable (`tree-structure-immutable`)
A persistent `ImmutableTreeNode` with structural sharing. Every operation (`addChild`,
`removeChild`, `mapValues`) returns a **new** root and leaves the original untouched; unchanged
subtrees are reused, so updates are cheap and old roots stay valid. Backed by
`kotlinx.collections.immutable`.
```kotlin
implementation("com.github.adriankuta:tree-structure-immutable:4.1.0")
```
```kotlin
val root = ImmutableTreeNode("World").addChild(ImmutableTreeNode("Europe"))
val bigger = root.addChild(ImmutableTreeNode("Asia")) // root is unchanged; bigger is a new tree
bigger.preOrder().forEach { println(it.value) } // pre/post/level-order, nodeCount(), height()
```
## Notes
`TreeNode` is mutable and not thread-safe. Add your own synchronization if you share a tree across

View File

@@ -11,7 +11,7 @@ plugins {
val PUBLISH_GROUP_ID = "com.github.adriankuta"
val PUBLISH_ARTIFACT_ID = "tree-structure" // base artifact; KMP will add -jvm, -ios*, etc.
val PUBLISH_VERSION = "4.0.0"
val PUBLISH_VERSION = "4.1.0"
val snapshot: String? by project