Files
Tree-Data-Structure/CHANGELOG.md
Adrian Kuta 69d19f89e3 feat!: v4.0 breaking API cleanup + explicitApi
BREAKING changes to the core:
- treeIterator is now a read-only `val`; added `iterator(order)` and use `asSequence(order)`.
- removeChild() only removes a direct child of the receiver; added `detach()` to unhook a node.
- addChild() rejects re-parenting and cycles (throws TreeNodeException); detach() first to move.
- clear() no longer nulls the receiver's own parent; only removes descendants.
- path() returns List<TreeNode<T>>? (null) instead of throwing.

Also:
- Enable strict explicitApi() across core + both modules; add explicit `public` modifiers.
- Update tests for the new contracts + add TreeNodeV4Test; refresh .api baselines.
- README + CHANGELOG (with migration notes); bump version to 4.0.0.

47 JVM tests green.
2026-06-07 18:47:40 +02:00

3.8 KiB

Changelog

All notable changes to this project are documented here. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

4.0.0

A breaking release that cleans up the core API and enforces an explicit public surface.

Changed (breaking)

  • TreeNode.treeIterator is now a read-only val (set it via the constructor). Use iterator(order) or asSequence(order) to traverse in a different order per call.
  • removeChild(child) now only removes a direct child of the receiver (previously it removed the node from its actual parent regardless). Use child.detach() to unhook a node from wherever it lives.
  • addChild(child) now throws TreeNodeException if child already has a parent or if the attachment would create a cycle. Call detach() first to move a node.
  • clear() no longer detaches the receiver from its own parent; it only removes its descendants.
  • path(descendant) now returns List<TreeNode<T>>? (null when descendant is the root or not a descendant) instead of throwing TreeNodeException.

Added

  • TreeNode.detach() — removes a node from its parent.
  • TreeNode.iterator(order) — a one-shot iterator in a specific order.
  • Strict explicitApi() mode across all modules.
  • New tree-structure-compose module: a LazyTree composable for Compose Multiplatform.

Migration

  • node.treeIterator = PostOrder; for (n in node) { … }for (n in node.asSequence(PostOrder)) { … }
  • root.removeChild(deepNode)deepNode.detach()
  • try { node.path(x) } catch (e: TreeNodeException) { … }node.path(x)?.let { … }

3.4.0

Added

  • Lazy Sequence traversal: asSequence(order), preOrderSequence(), postOrderSequence(), levelOrderSequence() — composes with the Kotlin stdlib and short-circuits.
  • Navigation extensions: isLeaf, degree, root(), ancestors(), siblings(), leaves(), descendants().
  • Functional extensions: findNode, filterNodes, anyNode, allNodes, countNodes, foldNodes, mapValues, deepCopy, structurallyEquals (all stack-safe).
  • New optional modules published as separate artifacts:
    • tree-structure-serializationkotlinx.serialization support via a TreeNodeDto.
    • tree-structure-coroutinesFlow traversal (asFlow, preOrderFlow, …).
  • CHANGELOG.md, expanded README examples, and class-level KDoc (thread-safety / complexity).

Changed

  • nodeCount(), height(), clear() and the post-order iterator are now iterative — deep or degenerate (linear) trees no longer throw StackOverflowError.
  • Migrated to Kotlin 2.x (K2 compiler) and introduced a Gradle version catalog.
  • Build now uses binary-compatibility-validator (committed .api baselines) and Kover.

3.1.5

Fixed

  • Removed a stray println in TreeNode.removeChild() that printed to stdout on every removal.

Removed

  • Deleted the Example.ws.kts worksheet and the kotlin("script-runtime") dependency from the published JVM artifact, plus the leftover ExampleUnitTest template test.

Changed

  • Bumped actions/checkout v2 → v4 in CI workflows.

3.1.4

  • Updated Kotlin and JS dependencies; added the wasmJs target.

3.1.3

  • iOS targets and Maven Central (Sonatype Central Portal) publishing.