feat: Add Storage overlay search

This commit is contained in:
Linnea Gräf
2024-11-18 20:53:20 +01:00
parent d37d13daca
commit 139fa705b3
9 changed files with 237 additions and 73 deletions

View File

@@ -10,4 +10,13 @@ object StringUtil {
}
fun Iterable<String>.unwords() = joinToString(" ")
fun nextLexicographicStringOfSameLength(string: String): String {
val next = StringBuilder(string)
while (next.lastOrNull() == Character.MAX_VALUE) next.setLength(next.length - 1)
if (next.isEmpty()) return "" // There is no upper bound. Fall back to the empty string
val lastIdx = next.indices.last
next[lastIdx] = (next[lastIdx] + 1)
return next.toString()
}
}