Persistent sorted maps and sets for Clojure/Script with log-time rank queries, nearest key lookups, and splitting operations.
data.avl is a Clojure and ClojureScript library that provides persistent sorted maps and sets implemented with AVL trees. It solves the need for efficient rank queries, nearest-key lookups, and splitting operations on sorted collections, which are not supported by Clojure's built-in sorted collections. The library serves as a drop-in replacement for core sorted maps and sets while adding specialized logarithmic-time operations.
Clojure and ClojureScript developers who work with sorted collections and require advanced operations like rank-based access, key proximity searches, or efficient splitting of sorted data. It is particularly useful for applications dealing with ordered datasets, such as indexes, range queries, or sorted caches.
Developers choose data.avl over Clojure's core sorted collections because it offers unique logarithmic-time operations like rank queries and nearest-key lookups, which are essential for certain algorithms and data processing tasks. Its full compatibility with core APIs and support for transients make it a seamless yet more powerful alternative for sorted collection needs.
Persistent sorted maps and sets with log-time rank queries
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports rank queries via nth and rank-of, nearest key lookups, and splitting by key or index, all in O(log n) time, as detailed in the README with code examples.
Provides sorted-map, sorted-map-by, sorted-set, and sorted-set-by as direct replacements for clojure.core functions, ensuring seamless integration with existing code.
Enables batch updates with transients for better performance during construction and modifications, with the README noting that transients outperform built-in non-transient updates.
Functions like subrange return first-class collections that are fully independent and support arbitrary modifications, preventing garbage collection issues.
Admits in the README that associative updates (assoc, dissoc) are somewhat slower compared to Clojure's built-in sorted collections, which can impact performance in update-heavy scenarios.
Adds a reference and two integers per key for transients, rank queries, and rebalancing, increasing memory usage, which is a trade-off for the advanced features.
Limited to AVL tree implementations and advanced operations, making it overkill for projects that only need basic sorted collections, with potentially less community support than core libraries.