/** * tags any entities contained in a std container that are within the radius of the single entity * parameter */ public static <T extends BaseGameEntity, conT extends List<? extends T>> void TagNeighbors( T entity, conT others, final double radius) { ListIterator<? extends T> it = others.listIterator(); // iterate through all entities checking for range while (it.hasNext()) { T curOb = it.next(); // first clear any current tag curOb.UnTag(); // work in distance squared to avoid sqrts Vector2D to = sub(curOb.Pos(), entity.Pos()); // the bounding radius of the other is taken into account by adding it // to the range double range = radius + curOb.BRadius(); // if entity within range, tag for further consideration if ((curOb != entity) && (to.LengthSq() < range * range)) { curOb.Tag(); } } // next entity }