Endian

sealed class Endian(source)

Big&Little endian utilities.

Inheritors

Types

Link copied to clipboard
data object Big : Endian

Implementation of the Endian abstraction which performs all operations using big-endian byte order.

Link copied to clipboard
data object Little : Endian

Implementation of the Endian abstraction which performs all operations using little-endian byte order.

Functions

Link copied to clipboard
abstract fun intFrom(source: ByteArray, offset: Int): Int

Convert 4 bytes from source ByteArray, starting at index offset, to an Int.

Link copied to clipboard
abstract fun intOf(b0: Byte, b1: Byte, b2: Byte, b3: Byte): Int

Convert 4 bytes to an Int.

Link copied to clipboard
abstract fun longFrom(source: ByteArray, offset: Int): Long

Convert 8 bytes from source ByteArray, starting at index offset, to a Long.

Link copied to clipboard
abstract fun longOf(b0: Byte, b1: Byte, b2: Byte, b3: Byte, b4: Byte, b5: Byte, b6: Byte, b7: Byte): Long

Convert 8 bytes to a Long.

Link copied to clipboard
fun pack(source: Int, dest: ByteArray, destOffset: Int): ByteArray

Packs 4 bytes from source Int into dest ByteArray, starting at destOffset.

fun pack(source: Long, dest: ByteArray, destOffset: Int): ByteArray

Packs 8 bytes from source Long into dest ByteArray, starting at destOffset.

fun pack(source: Short, dest: ByteArray, destOffset: Int): ByteArray

Packs 2 bytes from source Short into dest ByteArray, starting at destOffset.

fun pack(source: ByteArray, dest: IntArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int): IntArray

Packs Ints from source ByteArray (max size / 4 Ints) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest IntArray, starting at destOffset.

fun pack(source: ByteArray, dest: LongArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int): LongArray

Packs Longs from source ByteArray (max size / 8 Longs) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest LongArray, starting at destOffset.

fun pack(source: ByteArray, dest: ShortArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int): ShortArray

Packs Shorts from source ByteArray (max size / 2 Shorts) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ShortArray, starting at destOffset.

fun pack(source: Int, dest: ByteArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int = Int.SIZE_BYTES): ByteArray

Packs bytes from source Int (max 4 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

fun pack(source: IntArray, dest: ByteArray, destOffset: Int, sourceIndexStart: Int = 0, sourceIndexEnd: Int = source.size): ByteArray

Packs bytes from source IntArray (max size * 4 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

fun pack(source: Long, dest: ByteArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int = Long.SIZE_BYTES): ByteArray

Packs bytes from source Long (max 8 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

fun pack(source: LongArray, dest: ByteArray, destOffset: Int, sourceIndexStart: Int = 0, sourceIndexEnd: Int = source.size): ByteArray

Packs bytes from source LongArray (max size * 8 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

fun pack(source: Short, dest: ByteArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int = Short.SIZE_BYTES): ByteArray

Packs bytes from source Short (max 2 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

fun pack(source: ShortArray, dest: ByteArray, destOffset: Int, sourceIndexStart: Int = 0, sourceIndexEnd: Int = source.size): ByteArray

Packs bytes from source ShortArray (max size * 2 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

Link copied to clipboard
abstract fun packUnsafe(source: Int, dest: ByteArray, destOffset: Int): ByteArray

Packs 4 bytes from source Int into dest ByteArray, starting at destOffset.

abstract fun packUnsafe(source: Long, dest: ByteArray, destOffset: Int): ByteArray

Packs 8 bytes from source Long into dest ByteArray, starting at destOffset.

abstract fun packUnsafe(source: Short, dest: ByteArray, destOffset: Int): ByteArray

Packs 2 bytes from source Short into dest ByteArray, starting at destOffset.

abstract fun packUnsafe(source: ByteArray, dest: IntArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int): IntArray

Packs Ints from source ByteArray (max size / 4 Ints) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest IntArray, starting at destOffset.

abstract fun packUnsafe(source: ByteArray, dest: LongArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int): LongArray

Packs Longs from source ByteArray (max size / 8 Longs) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest LongArray, starting at destOffset.

abstract fun packUnsafe(source: ByteArray, dest: ShortArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int): ShortArray

Packs Shorts from source ByteArray (max size / 2 Shorts) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ShortArray, starting at destOffset.

abstract fun packUnsafe(source: Int, dest: ByteArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int = Int.SIZE_BYTES): ByteArray

Packs bytes from source Int (max 4 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset. If sourceIndexStart is 0 and sourceIndexEnd is Int.SIZE_BYTES, the more performant packUnsafe function will be utilized.

abstract fun packUnsafe(source: IntArray, dest: ByteArray, destOffset: Int, sourceIndexStart: Int = 0, sourceIndexEnd: Int = source.size): ByteArray

Packs bytes from source IntArray (max size * 4 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

abstract fun packUnsafe(source: Long, dest: ByteArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int = Long.SIZE_BYTES): ByteArray

Packs bytes from source Long (max 8 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset. If sourceIndexStart is 0 and sourceIndexEnd is Long.SIZE_BYTES, the more performant packUnsafe function will be utilized.

abstract fun packUnsafe(source: LongArray, dest: ByteArray, destOffset: Int, sourceIndexStart: Int = 0, sourceIndexEnd: Int = source.size): ByteArray

Packs bytes from source LongArray (max size * 8 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

abstract fun packUnsafe(source: Short, dest: ByteArray, destOffset: Int, sourceIndexStart: Int, sourceIndexEnd: Int = Short.SIZE_BYTES): ByteArray

Packs bytes from source Short (max 2 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset. If sourceIndexStart is 0 and sourceIndexEnd is Short.SIZE_BYTES, the more performant packUnsafe function will be utilized.

abstract fun packUnsafe(source: ShortArray, dest: ByteArray, destOffset: Int, sourceIndexStart: Int = 0, sourceIndexEnd: Int = source.size): ByteArray

Packs bytes from source ShortArray (max size * 2 bytes) from sourceIndexStart (inclusive) to sourceIndexEnd (exclusive) into dest ByteArray, starting at destOffset.

Link copied to clipboard
abstract fun shortFrom(source: ByteArray, offset: Int): Short

Convert 2 bytes from source ByteArray, starting at index offset, to a Short.

Link copied to clipboard
abstract fun shortOf(b0: Byte, b1: Byte): Short

Convert 2 bytes to a Short.