public synchronized void updateEntityPositionLookup(Entity e,HashSet<Coords> oldPositions){
  HashSet<Coords> newPositions=e.getOccupiedCoords();
  if (newPositions.equals(oldPositions)) {
    return;
  }
  if (oldPositions != null) {
    for (    Coords pos : oldPositions) {
      HashSet<Integer> posEntities=entityPosLookup.get(pos);
      if (posEntities != null) {
        posEntities.remove(e.getId());
      }
    }
  }
  for (  Coords pos : newPositions) {
    HashSet<Integer> posEntities=entityPosLookup.get(pos);
    if (posEntities == null) {
      posEntities=new HashSet<Integer>();
      posEntities.add(e.getId());
      entityPosLookup.put(pos,posEntities);
    }
 else {
      posEntities.add(e.getId());
    }
  }
}

public synchronized void updateEntityPositionLookup ( Entity e , HashSet < Coords > oldPositions ) { HashSet < Coords > newPositions = e . getOccupiedCoords ( ) ; if ( newPositions . equals ( oldPositions ) ) { return ; } if ( oldPositions != null ) { for ( Coords pos : oldPositions ) { HashSet < Integer > posEntities = entityPosLookup . get ( pos ) ; if ( posEntities != null ) { posEntities . remove ( e . getId ( ) ) ; } } } for ( Coords pos : newPositions ) { HashSet < Integer > posEntities = entityPosLookup . get ( pos ) ; if ( posEntities == null ) { posEntities = new HashSet < Integer > ( ) ; posEntities . add ( e . getId ( ) ) ; entityPosLookup . put ( pos , posEntities ) ; } else { posEntities . add ( e . getId ( ) ) ; } } }
updates the map that maps a position to the list of entity ' s in that position .
