PRopeChunk protocol extensions for the built-in chunk backends used by the rope kernel.
The rope kernel operates on opaque 'chunks' whose concrete type varies by rope variant:
Rope — APersistentVector chunks (arbitrary Clojure values) StringRope — java.lang.String chunks (UTF-16 code units) ByteRope — byte[] chunks (raw bytes, unsigned 0–255 semantics)
Each backend here provides the 13 primitive operations the kernel needs (length, slice, merge, nth, append, last, butlast, update, of, reduce-init, append-sb, splice, splice-split). The rope kernel dispatches through the PRopeChunk protocol so that rope-concat/split/splice/etc. are written once and work for every backend.
PRopeChunk is strictly an internal dispatch table — nothing outside the
kernel should depend on these methods directly. User-facing interop with
Clojure built-in collections lives in ordered-collections.types.interop.
PRopeChunk protocol extensions for the built-in chunk backends used by the rope kernel. The rope kernel operates on opaque 'chunks' whose concrete type varies by rope variant: Rope — APersistentVector chunks (arbitrary Clojure values) StringRope — java.lang.String chunks (UTF-16 code units) ByteRope — byte[] chunks (raw bytes, unsigned 0–255 semantics) Each backend here provides the 13 primitive operations the kernel needs (length, slice, merge, nth, append, last, butlast, update, of, reduce-init, append-sb, splice, splice-split). The rope kernel dispatches through the PRopeChunk protocol so that rope-concat/split/splice/etc. are written once and work for every backend. PRopeChunk is strictly an internal dispatch table — nothing outside the kernel should depend on these methods directly. User-facing interop with Clojure built-in collections lives in `ordered-collections.types.interop`.
No vars found in this namespace.
No vars found in this namespace.
Chunked implicit-index rope helpers.
Rope trees are ordered by position, not by comparator. Each node stores a chunk vector in the key slot and the total element count of the subtree in the value slot. Weight balancing is still performed by node count, while the subtree element counts support indexed operations.
Chunk Size Invariant (CSI) ───────────────────────── Every chunk has size in [min, target] except:
No chunk may exceed target.
This is analogous to a B-tree minimum fill factor. The rightmost exception exists because conj (the most frequent growth operation) appends to the rightmost chunk, so a short rightmost chunk is naturally filled by subsequent appends.
CSI is maintained by:
Chunked implicit-index rope helpers.
Rope trees are ordered by position, not by comparator. Each node stores a
chunk vector in the key slot and the total element count of the subtree in
the value slot. Weight balancing is still performed by node count, while the
subtree element counts support indexed operations.
Chunk Size Invariant (CSI)
─────────────────────────
Every chunk has size in [min, target] except:
- If the rope has 0 chunks: the rope is empty (root is nil).
- If the rope has 1 chunk: the chunk may be any size in [1, target].
- If the rope has >= 2 chunks: only the rightmost chunk may be smaller
than min (the 'runt'). All other chunks must be in [min, target].
No chunk may exceed target.
This is analogous to a B-tree minimum fill factor. The rightmost exception
exists because conj (the most frequent growth operation) appends to the
rightmost chunk, so a short rightmost chunk is naturally filled by
subsequent appends.
CSI is maintained by:
- rope-concat: position-aware boundary check + merge-boundary
- rope-split-at: ensure-split-parts (fringe repair on both halves)
- rope-subvec-root: ensure-left-fringe + ensure-right-fringe
- rope-conj-right: fills rightmost chunk, overflows to new node
- rope-pop-right: shrinks rightmost chunk, removes if empty
- coll->root: partition-all target produces valid chunkscljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |