int beginx = ((int) rect.x) / width;
int beginy = ((int) rect.y) / height;
int endx = ((int) (rect.x + rect.w)) / width;
int endy = ((int) (rect.y + rect.h)) / height;
Vec2i pos = new Vec2i(0, 0);
for (int y = beginy; y <= endy; y++) {
for (int x = beginx; x <= endx; x++) {
pos.set(x, y);
ArrayList<E> mapList = map.get(pos);
if (mapList == null) {
ArrayList<E> list = new ArrayList<E>();
list.add(e);
map.put(new Vec2i(x, y), list);
} else {
mapList.add(e);
}
}
}