I have a list of about 1000 entities that i need to go through on a regular basis and see which ones are in a certain range. However, looking through the list every time I need to get the new list seems a bit inefficient. Is there a better way to do this? This is somewhat of what I’m using now.
public ArrayList<Entity> getEntitiesInRage(int range, Entity center){
ArrayList<Entity> inRange = new ArrayList<Entity>();
for(Entity e: fullList){
if(e.getDistanceTo(center) >= range)
inRange.add(e);
}
return inRange();
}