commonMain.jetbrains.datalore.plot.builder.data.GroupUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lets-plot-common Show documentation
Show all versions of lets-plot-common Show documentation
Lets-Plot JVM package without rendering part
/*
* Copyright (c) 2019. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.plot.builder.data
object GroupUtil {
internal val SINGLE_GROUP = { _: Int -> 0 }
fun wrap(l: List): (Int) -> Int {
return { index ->
if (index > 0 && index < l.size)
l[index]!!.toInt()
else
0
}
}
fun wrap(groupByPointIndex: Map): (Int) -> Int {
return { groupByPointIndex[it]!! }
}
fun indicesByGroup(dataLength: Int, groups: (Int) -> Int): Map> {
val indicesByGroup = LinkedHashMap>()
for (i in 0 until dataLength) {
val group = groups(i)
if (!indicesByGroup.containsKey(group)) {
indicesByGroup[group] = ArrayList()
}
indicesByGroup[group]!!.add(i)
}
return indicesByGroup
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy