This site requires JavaScript, please enable it in your browser!
Greenfoot back
erdelf
erdelf wrote ...

2014/4/3

Distance list sorting

erdelf erdelf

2014/4/3

#
Is there a way to sort a list with actors after the distance to another Actor and return the one with the shortest distance and all that efficiently enough to work without much lag in the act method cycles`?
bourne bourne

2014/4/3

#
Do you need to actually sort a list to retrieve the closest Actor?
erdelf erdelf

2014/4/3

#
not really, i just need the closest Actor out of a List
bourne bourne

2014/4/3

#
Then you should be able to do it in O(n) time. No different than finding the min/max of a list.
erdelf erdelf

2014/4/3

#
yeah thx, i think i am too tired to code right now
You need to login to post a reply.