<br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 10:12 PM, Robert Poor <span dir="ltr"><<a href="mailto:rdpoor@gmail.com">rdpoor@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
So what I'll probably end up doing is to create a unique ID for each of my objects (either via toString() or some other construction-time device), and keeping the objects sorted in an array using the ID for a binary search function. It's not as fast as a hashmap, but it's faster than linear search.<br>
<br>
- rob<br></blockquote></div><br>Hmm, toString() (giving the memory pointer thingie) won't work if you want to be able to create two equal objects and use them like:<br><br>A x1;<br>"x" => <a href="http://x1.id">x1.id</a>;<br>
hashset.put(x1);<br>A y;<br>"y" => <a href="http://y.id">y.id</a>;<br>hashset.put(y);<br>A x2;<br>"x" => <a href="http://x2.id">x2.id</a>; // same as x1<br>if (hashset.contains(x2)) {<br> // You want this code to run here<br>
}<br><br clear="all"><br>-- <br>Release me, insect, or I will destroy the Cosmos!<br>