This commit is contained in:
@@ -77,7 +77,7 @@ fun ByteArray.toIntArray(
|
||||
|
||||
return toList()
|
||||
.chunked(4)
|
||||
.map { it.toInt(order) }
|
||||
.map { it.toByteArray().toInt(order) }
|
||||
.toIntArray()
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ fun ByteArray.toLongArray(
|
||||
|
||||
return toList()
|
||||
.chunked(8)
|
||||
.map { it.toLong(order) }
|
||||
.map { it.toByteArray().toLong(order) }
|
||||
.toLongArray()
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ fun ByteArray.toUIntArray(
|
||||
|
||||
return toList()
|
||||
.chunked(4)
|
||||
.map { it.toUInt(order) }
|
||||
.map { it.toByteArray().toUInt(order) }
|
||||
.toUIntArray()
|
||||
}
|
||||
|
||||
@@ -143,6 +143,6 @@ fun ByteArray.toULongArray(
|
||||
|
||||
return toList()
|
||||
.chunked(8)
|
||||
.map { it.toULong(order) }
|
||||
.map { it.toByteArray().toULong(order) }
|
||||
.toULongArray()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.infendro.bytearray
|
||||
|
||||
import com.infendro.bytearray.ByteOrder.BIG_ENDIAN
|
||||
|
||||
fun MutableCollection<Byte>.addAll(
|
||||
bytes: ByteArray,
|
||||
) = addAll(bytes.toList())
|
||||
@@ -9,67 +7,3 @@ fun MutableCollection<Byte>.addAll(
|
||||
fun MutableCollection<UByte>.addAll(
|
||||
bytes: UByteArray,
|
||||
) = addAll(bytes.toList())
|
||||
|
||||
fun Collection<Byte>.toInt(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toInt(order)
|
||||
|
||||
fun Collection<UByte>.toInt(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toInt(order)
|
||||
|
||||
fun Collection<Byte>.toIntArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toIntArray(order)
|
||||
|
||||
fun Collection<UByte>.toIntArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toIntArray(order)
|
||||
|
||||
fun Collection<Byte>.toLong(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toLong(order)
|
||||
|
||||
fun Collection<UByte>.toLong(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toLong(order)
|
||||
|
||||
fun Collection<Byte>.toLongArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toLongArray(order)
|
||||
|
||||
fun Collection<UByte>.toLongArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toLongArray(order)
|
||||
|
||||
fun Collection<Byte>.toUInt(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toUInt(order)
|
||||
|
||||
fun Collection<UByte>.toUInt(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toUInt(order)
|
||||
|
||||
fun Collection<Byte>.toUIntArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toUIntArray(order)
|
||||
|
||||
fun Collection<UByte>.toUIntArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toUIntArray(order)
|
||||
|
||||
fun Collection<Byte>.toULong(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toULong(order)
|
||||
|
||||
fun Collection<UByte>.toULong(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toULong(order)
|
||||
|
||||
fun Collection<Byte>.toULongArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toByteArray().toULongArray(order)
|
||||
|
||||
fun Collection<UByte>.toULongArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
) = toUByteArray().toULongArray(order)
|
||||
|
||||
@@ -74,7 +74,7 @@ fun UByteArray.toIntArray(
|
||||
|
||||
return toList()
|
||||
.chunked(4)
|
||||
.map { it.toInt(order) }
|
||||
.map { it.toUByteArray().toInt(order) }
|
||||
.toIntArray()
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ fun UByteArray.toLongArray(
|
||||
|
||||
return toList()
|
||||
.chunked(8)
|
||||
.map { it.toLong(order) }
|
||||
.map { it.toUByteArray().toLong(order) }
|
||||
.toLongArray()
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ fun UByteArray.toUIntArray(
|
||||
|
||||
return toList()
|
||||
.chunked(4)
|
||||
.map { it.toUInt(order) }
|
||||
.map { it.toUByteArray().toUInt(order) }
|
||||
.toUIntArray()
|
||||
}
|
||||
|
||||
@@ -140,6 +140,6 @@ fun UByteArray.toULongArray(
|
||||
|
||||
return toList()
|
||||
.chunked(8)
|
||||
.map { it.toULong(order) }
|
||||
.map { it.toUByteArray().toULong(order) }
|
||||
.toULongArray()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user