Hey, I found out that this: ``` var columns = list...
# stdlib
m
Hey, I found out that this:
Copy code
var columns = listOf<MutableList<EventRect>>()
for (eventRect in collisionGroup) {
    val properColumn = columns.firstOrNull { column -> !isEventsCollide(eventRect.event, column[column.size - 1].event) }
    if(properColumn != null) {
        properColumn.add(eventRect)
    } else {
        columns = columns.plusElement(mutableListOf(eventRect))
    }
}
is pretty common pattern. Like groupBy, but being in the group depend on other elements in this group. Like elements that are close enough to themself
v
marcinmoskala: I struggle to comprehend what this code does
Could you please reimplement a simplified version with standard classes? So that it could be run in try.kotlinlang.org
Well I don't have the definition of the
EventRect
class, that's a problem. Can't you function be demonstrated with
Int
or
String
or something similarly simple?
m
collisionGroup is group of events that are at the same time. This is finding columns for them the way that two events in the same column are not overlapping
Like in here
Groups of events that are in the same time needs to make small columns
v
OK, nice