Compare commits
2 Commits
ded3b31aa4
...
33d118430d
| Author | SHA1 | Date | |
|---|---|---|---|
|
33d118430d
|
|||
|
9efcd0e695
|
@@ -1,5 +1,5 @@
|
||||
group = "com.infendro"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
35
src/commonMain/kotlin/com/infendro/bytearray/operation.kt
Normal file
35
src/commonMain/kotlin/com/infendro/bytearray/operation.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.infendro.bytearray
|
||||
|
||||
import kotlin.experimental.and
|
||||
import kotlin.experimental.or
|
||||
import kotlin.experimental.xor
|
||||
|
||||
infix fun ByteArray.and(
|
||||
that: ByteArray,
|
||||
): ByteArray {
|
||||
if (this.size != that.size) throw Exception()
|
||||
|
||||
return ByteArray(size) { i ->
|
||||
this[i] and that[i]
|
||||
}
|
||||
}
|
||||
|
||||
infix fun ByteArray.or(
|
||||
that: ByteArray,
|
||||
): ByteArray {
|
||||
if (this.size != that.size) throw Exception()
|
||||
|
||||
return ByteArray(size) { i ->
|
||||
this[i] or that[i]
|
||||
}
|
||||
}
|
||||
|
||||
infix fun ByteArray.xor(
|
||||
that: ByteArray,
|
||||
): ByteArray {
|
||||
if (this.size != that.size) throw Exception()
|
||||
|
||||
return ByteArray(size) { i ->
|
||||
this[i] xor that[i]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user