Say I have multiple (MANY) Lists, each containing multiple Record objects that contain one long constructor parameter "time" (and a string parameter for debugging purposes).
Here is an example:
val list1 = listOf(Record(0, "A1"), Record(1, "A2"), Record(2, "A3"))
val list2 = listOf(Record(0, "B1"), Record(2, "B2"))
val list3 = listOf(Record(1, "C1"), Record(2, "C2"))
I want to combine the lists into one list, so that at any given time present in the original lists, the latest value from each list is present in the list.
Here is an example:
val output = listOf(Record(0, "A1+B1"), Record(1, "A2+B1+C1"), Record(2, "A3+B2+C2"))
Assume that Records can be added to create new Records containing the data of both.
(Technically, Records are a typealias for a key-value map containing data, but I thought that was out of scope for this question.)