Alexis Cala Martínez
01/20/2021, 5:57 AMMatteo Mirk
01/20/2021, 9:30 AMval mapSomeDTO = getSomeDTOList().associateBy { it.id }
Alexis Cala Martínez
01/20/2021, 1:58 PMMatteo Mirk
01/20/2021, 1:59 PMval hashMapSomeDTO = getSomeDTOList().associateByTo(HashMap()) { it.id }
Alexis Cala Martínez
01/20/2021, 3:23 PMMatteo Mirk
01/20/2021, 4:03 PMMap
reference if all you need is a fast lookup by id.
[By the way, a linear search on a list has an average complexity of O(n), but you can use a binary search which is O(log n)]Alexis Cala Martínez
01/21/2021, 4:42 AMMatteo Mirk
01/21/2021, 9:16 AM