implement typed array to byte array conversions
This commit is contained in:
@@ -73,8 +73,8 @@ fun UByteArray.toIntArray(
|
||||
if (size % 4 != 0) throw Exception()
|
||||
|
||||
return toList()
|
||||
.chunked(4)
|
||||
.map { it.toUByteArray().toInt(order) }
|
||||
.chunked(4) { it.toUByteArray() }
|
||||
.map { it.toInt(order) }
|
||||
.toIntArray()
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ fun UByteArray.toLongArray(
|
||||
if (size % 8 != 0) throw Exception()
|
||||
|
||||
return toList()
|
||||
.chunked(8)
|
||||
.map { it.toUByteArray().toLong(order) }
|
||||
.chunked(8) { it.toUByteArray() }
|
||||
.map { it.toLong(order) }
|
||||
.toLongArray()
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ fun UByteArray.toUIntArray(
|
||||
if (size % 4 != 0) throw Exception()
|
||||
|
||||
return toList()
|
||||
.chunked(4)
|
||||
.map { it.toUByteArray().toUInt(order) }
|
||||
.chunked(4) { it.toUByteArray() }
|
||||
.map { it.toUInt(order) }
|
||||
.toUIntArray()
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ fun UByteArray.toULongArray(
|
||||
if (size % 8 != 0) throw Exception()
|
||||
|
||||
return toList()
|
||||
.chunked(8)
|
||||
.map { it.toUByteArray().toULong(order) }
|
||||
.chunked(8) { it.toUByteArray() }
|
||||
.map { it.toULong(order) }
|
||||
.toULongArray()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user