semoro
09/07/2016, 5:16 AMval objects = LinkedList<SomeCommonObject>()
fun calledMultipleTimes(){
val someObject = getNotUniqueObject() //This object will be next unique for each 10k calls
objects.add(someObject)
}
fun calledOnce(){
objects.distinct().forEach { it.doSometingLikeNone() }
}
Or
val objects = LinkedList<SomeCommonObject>()
fun calledMultipleTimes(){
val someObject = getNotUniqueObject() //This object will be next unique for each 10k calls
if(someObject !in objects)
objects.add(someObject)
}
fun calledOnce(){
objects.forEach { it.doSometingLikeNone() }
}
Checked, answer is 2