implement optimizations
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.infendro.bytes.bytearray
|
||||
|
||||
import com.infendro.bytes.ubytearray.*
|
||||
|
||||
fun ByteArray.invInto(
|
||||
destination: ByteArray,
|
||||
destinationOffset: Int = 0,
|
||||
startIndex: Int = 0,
|
||||
endIndex: Int = size,
|
||||
) = asUByteArray().invInto(destination.asUByteArray(), destinationOffset, startIndex, endIndex)
|
||||
|
||||
fun ByteArray.inv() =
|
||||
(asUByteArray().inv()).asByteArray()
|
||||
|
||||
fun ByteArray.andInto(
|
||||
that: ByteArray,
|
||||
destination: ByteArray,
|
||||
destinationOffset: Int = 0,
|
||||
startIndex: Int = 0,
|
||||
endIndex: Int = size,
|
||||
thatStartIndex: Int = 0,
|
||||
) = asUByteArray().andInto(
|
||||
that.asUByteArray(),
|
||||
destination.asUByteArray(),
|
||||
destinationOffset,
|
||||
startIndex,
|
||||
endIndex,
|
||||
thatStartIndex,
|
||||
)
|
||||
|
||||
infix fun ByteArray.and(that: ByteArray) =
|
||||
(this.asUByteArray() and that.asUByteArray()).asByteArray()
|
||||
|
||||
fun ByteArray.orInto(
|
||||
that: ByteArray,
|
||||
destination: ByteArray,
|
||||
destinationOffset: Int = 0,
|
||||
startIndex: Int = 0,
|
||||
endIndex: Int = size,
|
||||
thatStartIndex: Int = 0,
|
||||
) = asUByteArray().orInto(
|
||||
that.asUByteArray(),
|
||||
destination.asUByteArray(),
|
||||
destinationOffset,
|
||||
startIndex,
|
||||
endIndex,
|
||||
thatStartIndex,
|
||||
)
|
||||
|
||||
infix fun ByteArray.or(that: ByteArray) =
|
||||
(this.asUByteArray() or that.asUByteArray()).asByteArray()
|
||||
|
||||
fun ByteArray.xorInto(
|
||||
that: ByteArray,
|
||||
destination: ByteArray,
|
||||
destinationOffset: Int = 0,
|
||||
startIndex: Int = 0,
|
||||
endIndex: Int = size,
|
||||
thatStartIndex: Int = 0,
|
||||
) = asUByteArray().xorInto(
|
||||
that.asUByteArray(),
|
||||
destination.asUByteArray(),
|
||||
destinationOffset,
|
||||
startIndex,
|
||||
endIndex,
|
||||
thatStartIndex,
|
||||
)
|
||||
|
||||
infix fun ByteArray.xor(that: ByteArray) =
|
||||
(this.asUByteArray() xor that.asUByteArray()).asByteArray()
|
||||
Reference in New Issue
Block a user