Change search result order for all other categories

This commit is contained in:
MM20
2024-10-13 20:32:15 +02:00
parent bf6e963545
commit 774777f79c
8 changed files with 179 additions and 165 deletions
@@ -45,7 +45,7 @@ value class ResultScore private constructor(private val packed: Long) : Comparab
* A total score for the result, combining the similarity with additional factors.
*/
val score: Float
get() = (similarity + (if (isPrefix) 0.8f else 0f) + (if (isSubstring) 0.8f else 0f)) * (if (isPrimary) 1f else 0.5f)
get() = (similarity + (if (isPrefix) 0.8f else 0f) + (if (isSubstring) 0.8f else 0f)) * (if (isPrimary) 1f else 0.8f)
override fun compareTo(other: ResultScore): Int {
return score.compareTo(other.score)
@@ -89,6 +89,15 @@ value class ResultScore private constructor(private val packed: Long) : Comparab
isPrimary = false,
similarity = 0f
)
}
}
val Unspecified = ResultScore(
isPrefix = false,
isSubstring = false,
isPrimary = false,
similarity = Float.NaN,
)
}
}
inline val ResultScore.isUnspecified : Boolean
get() = this == ResultScore.Unspecified
@@ -4,5 +4,5 @@ import kotlinx.coroutines.Deferred
interface Searchable {
val score: ResultScore
get() = ResultScore.Zero
get() = ResultScore.Unspecified
}