Liking cljdoc? Tell your friends :D

clj-uuid.bitmop

Unsigned Long and ByteBuffer-based bitwise operation primitives for UUID manipulation.

Provides the same mask/ldb/dpb fundamentals as in the past, plus a 16-byte ByteBuffer abstraction for direct UUID byte manipulation.

The ByteBuffer approach has two key advantages:

  1. Performance: ByteBuffer provides direct typed access at byte offsets via single native operations (getLong, getInt, etc.) rather than manual shift/mask loops.
  2. Portability: The buffer abstraction maps naturally to JavaScript's DataView/ArrayBuffer, enabling a future cljc implementation.
Unsigned Long and ByteBuffer-based bitwise operation primitives for
UUID manipulation.

Provides the same mask/ldb/dpb fundamentals as in the past, plus a
16-byte ByteBuffer abstraction for direct UUID byte manipulation.

The ByteBuffer approach has two key advantages:

1. Performance: ByteBuffer provides direct typed access at byte offsets
   via single native operations (getLong, getInt, etc.) rather than
   manual shift/mask loops.
2. Portability: The buffer abstraction maps naturally to JavaScript's
   DataView/ArrayBuffer, enabling a future cljc implementation.
raw docstring

assemble-bytesclj

(assemble-bytes v)

Assemble a sequence of 8 bytes (big-endian) into a long.

Assemble a sequence of 8 bytes (big-endian) into a long.
sourceraw docstring

bit-countclj

(bit-count x)

Count the number of set bits in x.

Count the number of set bits in `x`.
sourceraw docstring

buf->bytesclj

(buf->bytes buf)

Extract the contents of a 16-byte UUID buffer as a byte array.

Extract the contents of a 16-byte UUID buffer as a byte array.
sourceraw docstring

buf->uuidclj

(buf->uuid buf)

Convert a 16-byte UUID buffer to a java.util.UUID.

Convert a 16-byte UUID buffer to a java.util.UUID.
sourceraw docstring

buf-compareclj

(buf-compare a b)

Lexicographic unsigned comparison of two 16-byte UUID buffers. Returns negative if a < b, zero if equal, positive if a > b. Comparison is unsigned (treats bytes as 0-255) which matches UUID canonical string ordering.

Lexicographic unsigned comparison of two 16-byte UUID buffers.
Returns negative if a < b, zero if equal, positive if a > b.
Comparison is unsigned (treats bytes as 0-255) which matches UUID
canonical string ordering.
sourceraw docstring

buf-hexclj

(buf-hex buf)

Convert a 16-byte UUID buffer to a 32-character hex string.

Convert a 16-byte UUID buffer to a 32-character hex string.
sourceraw docstring

buf-strclj

(buf-str buf)

Convert a 16-byte UUID buffer to the canonical 36-character UUID string: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Byte ranges correspond to UUID fields: bytes 0-3: time-low bytes 4-5: time-mid bytes 6-7: time-high-and-version bytes 8-9: clock-seq bytes 10-15: node

Convert a 16-byte UUID buffer to the canonical 36-character UUID string:
  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Byte ranges correspond to UUID fields:
  bytes 0-3:   time-low
  bytes 4-5:   time-mid
  bytes 6-7:   time-high-and-version
  bytes 8-9:   clock-seq
  bytes 10-15: node
sourceraw docstring

bufferclj

(buffer)
(buffer msb lsb)

Create a 16-byte big-endian ByteBuffer.

0-arity: zeroed buffer 2-arity: from msb and lsb longs The buffer uses absolute (position-independent) get/put operations.

Create a 16-byte big-endian ByteBuffer.

0-arity:  zeroed buffer
2-arity:  from msb and lsb longs
The buffer uses absolute (position-independent) get/put operations.
sourceraw docstring

buffer-from-bytesclj

(buffer-from-bytes arr)

Create a 16-byte ByteBuffer from a byte array (at least 16 bytes).

Create a 16-byte ByteBuffer from a byte array (at least 16 bytes).
sourceraw docstring

bytes->longclj

(bytes->long arr i)

Read 8 bytes from arr starting at offset i, returning a long.

Read 8 bytes from `arr` starting at offset `i`, returning a long.
sourceraw docstring

dpbclj

(dpb bitmask num value)

Deposit Byte -- insert value into the bit field defined by bitmask within num.

Deposit Byte -- insert `value` into the bit field defined by `bitmask`
within `num`.
sourceraw docstring

dpb-bufclj

(dpb-buf buf word-offset bitmask value)

Deposit bit field: insert value into the bits defined by bitmask within the 64-bit word at word-offset in the buffer. Mutates and returns the buffer.

Deposit bit field: insert `value` into the bits defined by `bitmask`
within the 64-bit word at `word-offset` in the buffer.  Mutates and
returns the buffer.
sourceraw docstring

duplicateclj

(duplicate buf)

Create an independent copy of a UUID buffer.

Create an independent copy of a UUID buffer.
sourceraw docstring

expt2clj

(expt2 pow)

Compute 2^pow using bit-set.

Compute 2^pow using bit-set.
sourceraw docstring

get-byteclj

(get-byte buf offset)

Read an unsigned byte (0-255) at byte offset from buffer.

Read an unsigned byte (0-255) at byte offset from buffer.
sourceraw docstring

get-intclj

(get-int buf offset)

Read an unsigned 32-bit value at byte offset from buffer.

Read an unsigned 32-bit value at byte offset from buffer.
sourceraw docstring

get-longclj

(get-long buf offset)

Read a 64-bit long at byte offset from buffer.

Read a 64-bit long at byte offset from buffer.
sourceraw docstring

get-lsbclj

(get-lsb buf)

Read the least significant 64 bits (bytes 8-15) of a UUID buffer.

Read the least significant 64 bits (bytes 8-15) of a UUID buffer.
sourceraw docstring

get-msbclj

(get-msb buf)

Read the most significant 64 bits (bytes 0-7) of a UUID buffer.

Read the most significant 64 bits (bytes 0-7) of a UUID buffer.
sourceraw docstring

get-shortclj

(get-short buf offset)

Read an unsigned 16-bit value at byte offset from buffer.

Read an unsigned 16-bit value at byte offset from buffer.
sourceraw docstring

hexclj

(hex thing)

Convert a long or byte sequence to a hex string. For a long, produces a 16-character zero-padded hex string.

Convert a long or byte sequence to a hex string.
For a long, produces a 16-character zero-padded hex string.
sourceraw docstring

hex->bufclj

(hex->buf s)

Parse a 32-character hex string into a 16-byte UUID buffer.

Parse a 32-character hex string into a 16-byte UUID buffer.
sourceraw docstring

ldbclj

(ldb bitmask num)

Load Byte -- extract the bit field defined by bitmask from num.

Load Byte -- extract the bit field defined by `bitmask` from `num`.
sourceraw docstring

ldb-bufclj

(ldb-buf buf word-offset bitmask)

Load bit field: extract bits defined by bitmask from the 64-bit word at word-offset in the buffer.

Load bit field: extract bits defined by `bitmask` from the 64-bit word
at `word-offset` in the buffer.
sourceraw docstring

long->bytesclj

(long->bytes x)
(long->bytes x arr i)

Write x as 8 big-endian bytes. With one argument returns a new byte array. With three arguments writes into arr at offset i.

Write `x` as 8 big-endian bytes.  With one argument returns a new byte
array.  With three arguments writes into `arr` at offset `i`.
sourceraw docstring

maskclj

(mask width offset)

Create a bitmask of width bits starting at bit offset.

Create a bitmask of `width` bits starting at bit `offset`.
sourceraw docstring

mask-offsetclj

(mask-offset m)

Return the bit offset (position of least significant set bit) of a mask.

Return the bit offset (position of least significant set bit) of a mask.
sourceraw docstring

mask-widthclj

(mask-width m)

Return the number of set bits in a contiguous bitmask.

Return the number of set bits in a contiguous bitmask.
sourceraw docstring

octet-hexclj

(octet-hex num)

Convert a single byte value to a two-character uppercase hex string.

Convert a single byte value to a two-character uppercase hex string.
sourceraw docstring

pphexclj

(pphex x)

Pretty-print a long value in both hexadecimal and binary.

Pretty-print a long value in both hexadecimal and binary.
sourceraw docstring

put-byteclj

(put-byte buf offset val)

Write a byte value at byte offset in buffer. Returns the buffer.

Write a byte value at byte offset in buffer.  Returns the buffer.
sourceraw docstring

put-intclj

(put-int buf offset val)

Write a 32-bit value at byte offset in buffer. Returns the buffer.

Write a 32-bit value at byte offset in buffer.  Returns the buffer.
sourceraw docstring

put-longclj

(put-long buf offset val)

Write a 64-bit long at byte offset in buffer. Returns the buffer.

Write a 64-bit long at byte offset in buffer.  Returns the buffer.
sourceraw docstring

put-shortclj

(put-short buf offset val)

Write a 16-bit value at byte offset in buffer. Returns the buffer.

Write a 16-bit value at byte offset in buffer.  Returns the buffer.
sourceraw docstring

sb16clj

(sb16 num)
source

sb32clj

(sb32 num)
source

sb64clj

(sb64 num)
source

sb8clj

(sb8 num)
source

set-lsbclj

(set-lsb buf val)

Set the least significant 64 bits (bytes 8-15) of a UUID buffer. Returns the buffer.

Set the least significant 64 bits (bytes 8-15) of a UUID buffer.
Returns the buffer.
sourceraw docstring

set-msbclj

(set-msb buf val)

Set the most significant 64 bits (bytes 0-7) of a UUID buffer. Returns the buffer.

Set the most significant 64 bits (bytes 0-7) of a UUID buffer.
Returns the buffer.
sourceraw docstring

ub16clj

(ub16 num)
source

ub24clj

(ub24 num)
source

ub32clj

(ub32 num)
source

ub4clj

(ub4 num)
source

ub48clj

(ub48 num)
source

ub56clj

(ub56 num)
source

ub8clj

(ub8 num)
source

uuid->bufclj

(uuid->buf uuid)

Convert a java.util.UUID to a 16-byte ByteBuffer.

Convert a java.util.UUID to a 16-byte ByteBuffer.
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