Object2DArray#getOrElse
This commit is contained in:
parent
66b0f3ffd8
commit
c46e2086b5
@ -10,10 +10,8 @@
|
|||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/gson" />
|
<option value="$PROJECT_DIR$/gson" />
|
||||||
<option value="$PROJECT_DIR$/gson-linear-algebra" />
|
|
||||||
<option value="$PROJECT_DIR$/guava" />
|
<option value="$PROJECT_DIR$/guava" />
|
||||||
<option value="$PROJECT_DIR$/kommons-mc" />
|
<option value="$PROJECT_DIR$/kommons-mc" />
|
||||||
<option value="$PROJECT_DIR$/linear-algebra" />
|
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.15.0
|
projectVersion=2.15.1
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -89,6 +89,27 @@ class Object2DArray<T> private constructor(
|
|||||||
return mem[column * rows + row] as T
|
return mem[column * rows + row] as T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getOrNull(column: Int, row: Int): T? {
|
||||||
|
if (column !in 0 until columns || row !in 0 until rows)
|
||||||
|
return null
|
||||||
|
|
||||||
|
return mem[column * rows + row] as T
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOrElse(column: Int, row: Int, orElse: T): T {
|
||||||
|
if (column !in 0 until columns || row !in 0 until rows)
|
||||||
|
return orElse
|
||||||
|
|
||||||
|
return mem[column * rows + row] as T
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOrElse(column: Int, row: Int, orElse: () -> T): T {
|
||||||
|
if (column !in 0 until columns || row !in 0 until rows)
|
||||||
|
return orElse.invoke()
|
||||||
|
|
||||||
|
return mem[column * rows + row] as T
|
||||||
|
}
|
||||||
|
|
||||||
operator fun set(column: Int, row: Int, value: T) {
|
operator fun set(column: Int, row: Int, value: T) {
|
||||||
if (column !in 0 until columns || row !in 0 until rows)
|
if (column !in 0 until columns || row !in 0 until rows)
|
||||||
throw IndexOutOfBoundsException("Matrix index out of bounds: $column x $row, while this array has dimensions of $columns x $rows")
|
throw IndexOutOfBoundsException("Matrix index out of bounds: $column x $row, while this array has dimensions of $columns x $rows")
|
||||||
|
Loading…
Reference in New Issue
Block a user