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