Liking cljdoc? Tell your friends :D

ordered-collections.types.byte-rope

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.
raw docstring

byte-ropeclj

(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.
sourceraw docstring

byte-rope-bytesclj

(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.
sourceraw docstring

byte-rope-concatclj

(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.
sourceraw docstring

byte-rope-digestclj

(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.
sourceraw docstring

byte-rope-get-byteclj

(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.
sourceraw docstring

byte-rope-get-intclj

(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.
sourceraw docstring

byte-rope-get-int-leclj

(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.
sourceraw docstring

byte-rope-get-longclj

(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.
sourceraw docstring

byte-rope-get-long-leclj

(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.
sourceraw docstring

byte-rope-get-shortclj

(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.
sourceraw docstring

byte-rope-get-short-leclj

(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.
sourceraw docstring

byte-rope-hexclj

(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.
sourceraw docstring

byte-rope-index-ofclj

(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.
sourceraw docstring

byte-rope-input-streamclj

(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.
sourceraw docstring

byte-rope-writeclj

(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[].
sourceraw docstring

read-byte-ropeclj

(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.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close