mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 06:40:07 +00:00
several fixes in optionallyReverse
This commit is contained in:
parent
d619d59947
commit
0202988cae
@ -39,11 +39,25 @@ fun <T> Set<T>.paginate(with: Pagination): PaginationResult<T> {
|
||||
)
|
||||
}
|
||||
|
||||
fun <T> Iterable<T>.optionallyReverse(reverse: Boolean) = if (reverse) {
|
||||
fun <T> Iterable<T>.optionallyReverse(reverse: Boolean): Iterable<T> = when (this) {
|
||||
is List<T> -> optionallyReverse(reverse)
|
||||
is Set<T> -> optionallyReverse(reverse)
|
||||
else -> if (reverse) {
|
||||
reversed()
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
fun <T> List<T>.optionallyReverse(reverse: Boolean): List<T> = if (reverse) {
|
||||
reversed()
|
||||
} else {
|
||||
this
|
||||
}
|
||||
fun <T> Set<T>.optionallyReverse(reverse: Boolean): Set<T> = if (reverse) {
|
||||
reversed().toSet()
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
inline fun <reified T> Array<T>.optionallyReverse(reverse: Boolean) = if (reverse) {
|
||||
Array(size) {
|
||||
|
Loading…
Reference in New Issue
Block a user