Zero-dependency Java tree library featuring binary and N-ary families with JMH benchmarks and hardware-counter-backed performance evidence.
18
stars
408
commits
Java
primary language
Sep 12, 2026
updated
ChaosTree is a Java Sorted Set/Map library built around multiple search-tree data structures, including AVL Trees, Red-Black Trees, B-Trees, and B+ Trees.
The library provides both Set and Map implementations, with APIs designed around the semantics of the JDK's NavigableSet, NavigableMap, SequencedSet, and SequencedMap contracts.
In addition to the standard collection APIs, ChaosTree provides specialized construction APIs for users who want direct control over the initial structure of N-ary trees, Do read
buildFromSorted(Iterator, factor)importFlatMatrix(Object[][], factor)These APIs allow users to control the target node occupancy through a configurable factor in the supported range [0.5, 1.0], while maintaining the structural invariants required by the underlying B-Tree/B+Tree design.
ChaosTree is validated through multiple layers of testing:
The structural tests inspect the internal tree representation rather than relying solely on externally observable behavior. This provides an additional layer of validation for node occupancy, ordering, topology, and balancing invariants.
Performance claims are backed by reproducible JMH benchmark configurations. If a referenced benchmark source is missing from the repository due to project cleanup, it can be restored or replaced with an updated benchmark.
SequencedCollection, SequencedSet, and SequencedMap interfaces. It passes the Guava Testlib (214,000+ tests) to enforce identical semantics to java.util.TreeMap and TreeSet.Details about ChaosTree: https://chaos-vy.github.io/ChaosTree/index.html
(Note: As strictly sorted structures, addFirst() and addLast() are unsupported and fail-fast).
<dependency>
<groupId>io.github.chaos-vy</groupId>
<artifactId>chaos-tree</artifactId>
<version>2.0.0</version>
</dependency>
implementation("io.github.chaos-vy:chaos-tree:2.0.0")
Create a highly-optimized BPlusTreeMap to leverage the N-ary engine:
import chaos.tree.naryMap.BPlusTreeMap;
import java.util.NavigableMap;
public class Main {
public static void main(String[] args) {
// Degree 64 B+Tree Map
NavigableMap<Integer, String> map = new BPlusTreeMap<>();
map.put(1, "Chaos");
map.put(2, "Tree");
map.put(3, "Performance");
// Instant range scans traversing the contiguous leaf-linked list
NavigableMap<Integer, String> subMap = map.subMap(1, true, 3, true);
System.out.println(subMap);
}
}
ChaosTree is split into two foundational engines:
BTree, BPlusTree. Built for maximum read throughput, large-scale range scans, and zero GC churn. The BPlusTree pushes all real data to a contiguous double linked-list at the bottom layer, allowing high read through put.AVL, RBT, . Built for fast point-queries and everyday data storage where the extreme caching of the N-ary engine is not required.I wanted ChaosTree to be correct just as much as I wanted it to be fast. It is validated by these following testing suite:
java.util.NavigableMap and NavigableSet for all tree.jqwik to verify structural invariants against a source-of-truth (java.util.TreeMap). Due to Nary API node structure of 32 the new node never got created in Guava So I explicitly designed the verify API which verify explicitly for that.ConcurrentModificationException iterator semantics, exact size counting, and strict Null-Pointer guards on custom Comparators.docs/ADR.htmldocs/utils/JMH-Report.htmldocs/Benchmark_Analysis.htmldocs/Test_Journey.htmlCHANGELOG.mdCONTRIBUTING.mdPull requests and well-scoped issue reports for compatibility, correctness, and maintenance work are welcome!
408 commits
Java
100.0%
Zero-dependency Java tree library featuring binary and N-ary families with JMH benchmarks and hardware-counter-backed performance evidence.
18
stars
408
commits
Java
primary language
Sep 12, 2026
updated
ChaosTree is a Java Sorted Set/Map library built around multiple search-tree data structures, including AVL Trees, Red-Black Trees, B-Trees, and B+ Trees.
The library provides both Set and Map implementations, with APIs designed around the semantics of the JDK's NavigableSet, NavigableMap, SequencedSet, and SequencedMap contracts.
In addition to the standard collection APIs, ChaosTree provides specialized construction APIs for users who want direct control over the initial structure of N-ary trees, Do read
buildFromSorted(Iterator, factor)importFlatMatrix(Object[][], factor)These APIs allow users to control the target node occupancy through a configurable factor in the supported range [0.5, 1.0], while maintaining the structural invariants required by the underlying B-Tree/B+Tree design.
ChaosTree is validated through multiple layers of testing:
The structural tests inspect the internal tree representation rather than relying solely on externally observable behavior. This provides an additional layer of validation for node occupancy, ordering, topology, and balancing invariants.
Performance claims are backed by reproducible JMH benchmark configurations. If a referenced benchmark source is missing from the repository due to project cleanup, it can be restored or replaced with an updated benchmark.
SequencedCollection, SequencedSet, and SequencedMap interfaces. It passes the Guava Testlib (214,000+ tests) to enforce identical semantics to java.util.TreeMap and TreeSet.Details about ChaosTree: https://chaos-vy.github.io/ChaosTree/index.html
(Note: As strictly sorted structures, addFirst() and addLast() are unsupported and fail-fast).
<dependency>
<groupId>io.github.chaos-vy</groupId>
<artifactId>chaos-tree</artifactId>
<version>2.0.0</version>
</dependency>
implementation("io.github.chaos-vy:chaos-tree:2.0.0")
Create a highly-optimized BPlusTreeMap to leverage the N-ary engine:
import chaos.tree.naryMap.BPlusTreeMap;
import java.util.NavigableMap;
public class Main {
public static void main(String[] args) {
// Degree 64 B+Tree Map
NavigableMap<Integer, String> map = new BPlusTreeMap<>();
map.put(1, "Chaos");
map.put(2, "Tree");
map.put(3, "Performance");
// Instant range scans traversing the contiguous leaf-linked list
NavigableMap<Integer, String> subMap = map.subMap(1, true, 3, true);
System.out.println(subMap);
}
}
ChaosTree is split into two foundational engines:
BTree, BPlusTree. Built for maximum read throughput, large-scale range scans, and zero GC churn. The BPlusTree pushes all real data to a contiguous double linked-list at the bottom layer, allowing high read through put.AVL, RBT, . Built for fast point-queries and everyday data storage where the extreme caching of the N-ary engine is not required.I wanted ChaosTree to be correct just as much as I wanted it to be fast. It is validated by these following testing suite:
java.util.NavigableMap and NavigableSet for all tree.jqwik to verify structural invariants against a source-of-truth (java.util.TreeMap). Due to Nary API node structure of 32 the new node never got created in Guava So I explicitly designed the verify API which verify explicitly for that.ConcurrentModificationException iterator semantics, exact size counting, and strict Null-Pointer guards on custom Comparators.docs/ADR.htmldocs/utils/JMH-Report.htmldocs/Benchmark_Analysis.htmldocs/Test_Journey.htmlCHANGELOG.mdCONTRIBUTING.mdPull requests and well-scoped issue reports for compatibility, correctness, and maintenance work are welcome!
408 commits
Java
100.0%