What is the most idomatic way to index a list of objects by coordinates
<p>I have a strong python background and a total newbie with Java, so I try to do things in <em>Pythonic</em> way in java and end up struggling. Currently I have a problem to figure out how to do store objects, indexed by coordinates, so that they are iterable. I <em>could</em> create an 2-dimensional array of the objects, but I'm afraid that would take a lot of memory <strong>AND</strong> I would have to iterate over all the indexes every time (when I only want to do it occassionally) to get all the objects.</p>

<p>In python, I would use a dictionary with tuples as keys, but looks like such thing is not possible in Java.</p>

<p>E.g.</p>

<pre><code>class bar()
    pass

bar1 = bar()
bar2 = bar()
# etc

foo = { (0,1): bar1, (100,30): bar2 }

for x in foo.values():
    do_something()
</code></pre>
