On Wed, Sep 30, 2009 at 10:12 PM, Robert Poor <rdpoor@gmail.com> wrote:


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.

- rob

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:

A x1;
"x" => x1.id;
hashset.put(x1);
A y;
"y" => y.id;
hashset.put(y);
A x2;
"x" => x2.id; // same as x1
if (hashset.contains(x2)) {
    // You want this code to run here
}


--
Release me, insect, or I will destroy the Cosmos!