Another way is: instead of storing entities by location have each entity store its own location and simply store them in an agnostic container. Pick a container that will allow you to quickly locate entities matching a position through iteration.
Which method is better depends on what you're doing. Having entities store their own location means that isolating all entities in a specific location takes longer. Having locations store more than one entity means iterating through all entities takes longer.
There's also the possibility of hybridization. That is, have a master list of entities which are aware of their own location and also retain a 2D array of containers that point to all entities that occupy each location. This is the most expensive in terms of storage and architecture but has the best access time for any method.