title: Java map based on object reference?
body: <p>So, I'd like to use a java map where the keys are an object...but rather than keying on the object's value, they key on the object ID. So, something like the following would be totally valid code:</p>
  
  <pre><code>Map&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;();
  
  String s1 = "hi!";
  String s2 = "hi!";
  
  map.put(s1, 10);
  map.put(s2, 47);
  </code></pre>
  
  <p>Is this possible? Is there a simple way to do this without building an object ID or something overly cumbersome in my class? Basically, I need a way to associate an ever-changing list of values with a given object. This list of values will potentially be different for objects that have the same value, hence why the default map doesn't work. Other than refactoring my class to do this myself (not really an option, given the time) is there anything that I could use?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: Further information.</p>
  
  <p>The example above was just an example. What I will be using this for is the implementation of a Uniform-Cost search algorithm. For any given node in a search with this algorithm, one must also have the path that has been taken so far. The reason a value-based hash map doesn't work is that this algorithm can reiterate over already-explored nodes. The paths would be different at this point, although the value of "where am I now?" is identical.</p>