mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-04 23:59:29 +00:00
intersect
This commit is contained in:
@@ -5,3 +5,13 @@ plugins {
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":micro_utils.common")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.micro_utils.pagination
|
||||
|
||||
import dev.inmo.micro_utils.common.intersect
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
|
||||
@@ -27,6 +28,12 @@ interface Pagination : ClosedRange<Int> {
|
||||
get() = lastIndex
|
||||
}
|
||||
|
||||
fun Pagination.intersect(
|
||||
other: Pagination
|
||||
): Pagination? = (this as ClosedRange<Int>).intersect(other as ClosedRange<Int>) ?.let {
|
||||
PaginationByIndexes(it.first, it.second)
|
||||
}
|
||||
|
||||
/**
|
||||
* Logical shortcut for comparison that page is 0
|
||||
*/
|
||||
|
Reference in New Issue
Block a user