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