Array2D.fill
This commit is contained in:
parent
78c3a3c35e
commit
536b81e27b
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.7.1
|
projectVersion=2.7.2
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -18,6 +18,14 @@ abstract class Boolean2DArray : Array2D() {
|
|||||||
|
|
||||||
open fun contentEquals(other: Boolean2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Boolean2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
|
open fun fill(value: Boolean) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return matrixEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
return matrixEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
}
|
}
|
||||||
@ -54,6 +62,13 @@ abstract class Boolean2DArray : Array2D() {
|
|||||||
mem[column + row * columns] = value
|
mem[column + row * columns] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Boolean) {
|
||||||
|
if (value)
|
||||||
|
mem.set(0, columns * rows)
|
||||||
|
else
|
||||||
|
mem.clear(0, columns * rows)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return mem == other.mem
|
if (other is Impl) return mem == other.mem
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -17,6 +17,14 @@ abstract class Byte2DArray : Array2D() {
|
|||||||
|
|
||||||
open fun contentEquals(other: Byte2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Byte2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
|
open fun fill(value: Byte) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return matrixEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
return matrixEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
}
|
}
|
||||||
@ -55,6 +63,10 @@ abstract class Byte2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Byte) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -20,6 +20,14 @@ abstract class Char2DArray : Array2D() {
|
|||||||
fun load(from: Char2DArray) { matrixLoad(from, this, Char2DArray::get, Char2DArray::set) }
|
fun load(from: Char2DArray) { matrixLoad(from, this, Char2DArray::get, Char2DArray::set) }
|
||||||
fun storeTransposed(from: Char2DArray) { matrixLoadTransposed(from, this, Char2DArray::get, Char2DArray::set) }
|
fun storeTransposed(from: Char2DArray) { matrixLoadTransposed(from, this, Char2DArray::get, Char2DArray::set) }
|
||||||
|
|
||||||
|
open fun fill(value: Char) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun contentEquals(other: Char2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Char2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
@ -60,6 +68,10 @@ abstract class Char2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Char) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -20,6 +20,14 @@ abstract class Double2DArray : Array2D() {
|
|||||||
fun load(from: Double2DArray) { matrixLoad(from, this, Double2DArray::get, Double2DArray::set) }
|
fun load(from: Double2DArray) { matrixLoad(from, this, Double2DArray::get, Double2DArray::set) }
|
||||||
fun storeTransposed(from: Double2DArray) { matrixLoadTransposed(from, this, Double2DArray::get, Double2DArray::set) }
|
fun storeTransposed(from: Double2DArray) { matrixLoadTransposed(from, this, Double2DArray::get, Double2DArray::set) }
|
||||||
|
|
||||||
|
open fun fill(value: Double) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun contentEquals(other: Double2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Double2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
open fun add(other: Double2DArray): Double2DArray = matrixPlainOperator(this, other, Double2DArray::get, Double::plus, Double2DArray::set)
|
open fun add(other: Double2DArray): Double2DArray = matrixPlainOperator(this, other, Double2DArray::get, Double::plus, Double2DArray::set)
|
||||||
@ -107,6 +115,10 @@ abstract class Double2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Double) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -20,6 +20,14 @@ abstract class Float2DArray : Array2D() {
|
|||||||
fun load(from: Float2DArray) { matrixLoad(from, this, Float2DArray::get, Float2DArray::set) }
|
fun load(from: Float2DArray) { matrixLoad(from, this, Float2DArray::get, Float2DArray::set) }
|
||||||
fun storeTransposed(from: Float2DArray) { matrixLoadTransposed(from, this, Float2DArray::get, Float2DArray::set) }
|
fun storeTransposed(from: Float2DArray) { matrixLoadTransposed(from, this, Float2DArray::get, Float2DArray::set) }
|
||||||
|
|
||||||
|
open fun fill(value: Float) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun contentEquals(other: Float2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Float2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
open fun add(other: Float2DArray): Float2DArray = matrixPlainOperator(this, other, Float2DArray::get, Float::plus, Float2DArray::set)
|
open fun add(other: Float2DArray): Float2DArray = matrixPlainOperator(this, other, Float2DArray::get, Float::plus, Float2DArray::set)
|
||||||
@ -108,6 +116,10 @@ abstract class Float2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Float) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -20,6 +20,14 @@ abstract class Int2DArray : Array2D() {
|
|||||||
fun load(from: Int2DArray) { matrixLoad(from, this, Int2DArray::get, Int2DArray::set) }
|
fun load(from: Int2DArray) { matrixLoad(from, this, Int2DArray::get, Int2DArray::set) }
|
||||||
fun storeTransposed(from: Int2DArray) { matrixLoadTransposed(from, this, Int2DArray::get, Int2DArray::set) }
|
fun storeTransposed(from: Int2DArray) { matrixLoadTransposed(from, this, Int2DArray::get, Int2DArray::set) }
|
||||||
|
|
||||||
|
open fun fill(value: Int) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun contentEquals(other: Int2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Int2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
open fun add(other: Int2DArray): Int2DArray = matrixPlainOperator(this, other, Int2DArray::get, Int::plus, Int2DArray::set)
|
open fun add(other: Int2DArray): Int2DArray = matrixPlainOperator(this, other, Int2DArray::get, Int::plus, Int2DArray::set)
|
||||||
@ -107,6 +115,10 @@ abstract class Int2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Int) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -20,6 +20,14 @@ abstract class Long2DArray : Array2D() {
|
|||||||
fun load(from: Long2DArray) { matrixLoad(from, this, Long2DArray::get, Long2DArray::set) }
|
fun load(from: Long2DArray) { matrixLoad(from, this, Long2DArray::get, Long2DArray::set) }
|
||||||
fun storeTransposed(from: Long2DArray) { matrixLoadTransposed(from, this, Long2DArray::get, Long2DArray::set) }
|
fun storeTransposed(from: Long2DArray) { matrixLoadTransposed(from, this, Long2DArray::get, Long2DArray::set) }
|
||||||
|
|
||||||
|
open fun fill(value: Long) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun contentEquals(other: Long2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Long2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
open fun add(other: Long2DArray): Long2DArray = matrixPlainOperator(this, other, Long2DArray::get, Long::plus, Long2DArray::set)
|
open fun add(other: Long2DArray): Long2DArray = matrixPlainOperator(this, other, Long2DArray::get, Long::plus, Long2DArray::set)
|
||||||
@ -107,6 +115,10 @@ abstract class Long2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Long) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
@ -64,6 +64,10 @@ class Object2DArray<T> private constructor(
|
|||||||
return matrixToString(this) { a, b, c -> a[b, c].toString() }
|
return matrixToString(this) { a, b, c -> a[b, c].toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fill(value: T) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
fun store(into: Object2DArray<T>) {
|
fun store(into: Object2DArray<T>) {
|
||||||
into.load(this)
|
into.load(this)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,14 @@ abstract class Short2DArray : Array2D() {
|
|||||||
fun load(from: Short2DArray) { matrixLoad(from, this, Short2DArray::get, Short2DArray::set) }
|
fun load(from: Short2DArray) { matrixLoad(from, this, Short2DArray::get, Short2DArray::set) }
|
||||||
fun storeTransposed(from: Short2DArray) { matrixLoadTransposed(from, this, Short2DArray::get, Short2DArray::set) }
|
fun storeTransposed(from: Short2DArray) { matrixLoadTransposed(from, this, Short2DArray::get, Short2DArray::set) }
|
||||||
|
|
||||||
|
open fun fill(value: Short) {
|
||||||
|
for (x in 0 until rows) {
|
||||||
|
for (y in 0 until columns) {
|
||||||
|
this[x, y] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open fun contentEquals(other: Short2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
open fun contentEquals(other: Short2DArray): Boolean = matrixContentEquals(this, other) { a, b, c, d -> a[c, d] == b[c, d] }
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
@ -60,6 +68,10 @@ abstract class Short2DArray : Array2D() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun fill(value: Short) {
|
||||||
|
mem.fill(value)
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
if (other is Impl) return sizeEquals(other) && mem.contentEquals(other.mem)
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
Loading…
Reference in New Issue
Block a user