Persistent byte rope optimized for structural editing of binary data. Backed by a chunked weight-balanced tree with byte[] chunks. O(log n) concat, split, splice, insert, and remove.
Bytes are exposed as unsigned longs in [0, 255]. Storage is signed Java bytes (same bits). Equality with byte[] is content-based; equality with Clojure vectors is always false to avoid signed/unsigned confusion.
Small byte sequences (≤ +flat-threshold+ bytes) are stored as a raw byte[] internally, giving byte[]-equivalent performance on reads. When edits grow past the threshold, the representation is transparently promoted to chunked tree form.
Persistent byte rope optimized for structural editing of binary data. Backed by a chunked weight-balanced tree with byte[] chunks. O(log n) concat, split, splice, insert, and remove. Bytes are exposed as unsigned longs in [0, 255]. Storage is signed Java bytes (same bits). Equality with byte[] is content-based; equality with Clojure vectors is always false to avoid signed/unsigned confusion. Small byte sequences (≤ +flat-threshold+ bytes) are stored as a raw byte[] internally, giving byte[]-equivalent performance on reads. When edits grow past the threshold, the representation is transparently promoted to chunked tree form.
(byte-rope)(byte-rope x)Create a persistent byte rope for structural editing of binary data. Backed by a chunked weight-balanced tree with byte[] chunks: O(log n) concat, split, splice, insert, and remove.
Bytes are exposed as unsigned longs in [0, 255]. Storage is signed Java bytes. Use the input as raw bytes:
(byte-rope) ;=> empty (byte-rope (byte-array [1 2 3])) ;=> from byte[] (defensively copied) (byte-rope [0 128 255]) ;=> from seq of unsigned longs (byte-rope "hello") ;=> UTF-8 encoding of the string
Small byte sequences (≤ 1024 bytes) are stored as a raw byte[] internally for zero-overhead reads. Edits that grow past the threshold are transparently promoted to chunked tree form.
Create a persistent byte rope for structural editing of binary data. Backed by a chunked weight-balanced tree with byte[] chunks: O(log n) concat, split, splice, insert, and remove. Bytes are exposed as unsigned longs in [0, 255]. Storage is signed Java bytes. Use the input as raw bytes: (byte-rope) ;=> empty (byte-rope (byte-array [1 2 3])) ;=> from byte[] (defensively copied) (byte-rope [0 128 255]) ;=> from seq of unsigned longs (byte-rope "hello") ;=> UTF-8 encoding of the string Small byte sequences (≤ 1024 bytes) are stored as a raw byte[] internally for zero-overhead reads. Edits that grow past the threshold are transparently promoted to chunked tree form.
(byte-rope-bytes br)Materialize a byte rope to a byte[]. Defensive copy — the caller may mutate the returned array without affecting the rope.
Materialize a byte rope to a byte[]. Defensive copy — the caller may mutate the returned array without affecting the rope.
(byte-rope-concat x)(byte-rope-concat left right)(byte-rope-concat left right & more)Concatenate byte ropes or byte arrays. One argument: returns it as a byte rope. Two arguments: O(log n) binary tree join. Three or more: O(total chunks) bulk construction.
Concatenate byte ropes or byte arrays. One argument: returns it as a byte rope. Two arguments: O(log n) binary tree join. Three or more: O(total chunks) bulk construction.
(byte-rope-digest br algorithm)Compute a cryptographic digest of the byte rope's contents using the named algorithm ("SHA-256", "SHA-1", "MD5", etc.). Streams chunks through java.security.MessageDigest without materializing the whole rope. Returns a byte rope of the digest.
Compute a cryptographic digest of the byte rope's contents using the
named algorithm ("SHA-256", "SHA-1", "MD5", etc.). Streams chunks
through java.security.MessageDigest without materializing the whole
rope. Returns a byte rope of the digest.(byte-rope-get-byte br offset)Return the unsigned byte value (long in [0, 255]) at offset.
Return the unsigned byte value (long in [0, 255]) at offset.
(byte-rope-get-int br offset)Return a big-endian signed 32-bit integer (long with int sign extension) at offset. Reads four bytes.
Return a big-endian signed 32-bit integer (long with int sign extension) at offset. Reads four bytes.
(byte-rope-get-int-le br offset)Return a little-endian signed 32-bit integer (long with int sign extension) at offset.
Return a little-endian signed 32-bit integer (long with int sign extension) at offset.
(byte-rope-get-long br offset)Return a big-endian signed 64-bit integer at offset. Reads eight bytes.
Return a big-endian signed 64-bit integer at offset. Reads eight bytes.
(byte-rope-get-long-le br offset)Return a little-endian signed 64-bit integer at offset.
Return a little-endian signed 64-bit integer at offset.
(byte-rope-get-short br offset)Return a big-endian unsigned 16-bit integer (long in [0, 65535]) at offset. Reads two bytes starting at offset.
Return a big-endian unsigned 16-bit integer (long in [0, 65535]) at offset. Reads two bytes starting at offset.
(byte-rope-get-short-le br offset)Return a little-endian unsigned 16-bit integer (long in [0, 65535]) at offset.
Return a little-endian unsigned 16-bit integer (long in [0, 65535]) at offset.
(byte-rope-hex br)Return the byte rope's contents as a lowercase hex string.
Return the byte rope's contents as a lowercase hex string.
(byte-rope-index-of br byte-val)(byte-rope-index-of br byte-val from)Return the index of the first occurrence of the unsigned byte value
(0–255) in the byte rope, or -1 if not found. Optional from position.
Return the index of the first occurrence of the unsigned byte value (0–255) in the byte rope, or -1 if not found. Optional `from` position.
(byte-rope-input-stream br)Return a java.io.InputStream that reads over the byte rope's contents. Stateful — each call returns a fresh stream.
Return a java.io.InputStream that reads over the byte rope's contents. Stateful — each call returns a fresh stream.
(byte-rope-write br out)Stream a byte rope's contents to an OutputStream, chunk by chunk. Writes each chunk via one OutputStream.write call so large ropes don't materialize the whole content as a single byte[].
Stream a byte rope's contents to an OutputStream, chunk by chunk. Writes each chunk via one OutputStream.write call so large ropes don't materialize the whole content as a single byte[].
(read-byte-rope hex)Reader function for #byte/rope tagged literals. Input is a hex string.
Reader function for #byte/rope tagged literals. Input is a hex string.
cljdoc 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 |