diana4sb / xbee-api

Automatically exported from code.google.com/p/xbee-api
GNU General Public License v3.0
0 stars 0 forks source link

XBeeAddress64 objects with equal address do not have the same hashcode #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am using a HashMap with XBeeAddress64 objects as keys, and overwriting the 
mapped values for those keys upon the reception of new data.  However, since 
the address objects do not return the same value for hashCode(), the HashMap 
created a new entry with each new value.  I fixed this by overriding hashCode() 
in XBeeAddress64.java with the following function:

    public int hashCode() {
        int val = 0;
        for (int i = 0; i < 4; i++) {
            val |= address[i] << (i * 8);
        }
        return val;
    }

Which should set the hashcode as the least significant 32-bits of the address.

I hope this is useful information for this project.  Thank you for all of your 
work on this API, it is proving to be extremely beneficial.

Original issue reported on code.google.com by LIGC90 on 28 Jun 2010 at 5:47

GoogleCodeExporter commented 9 years ago
Scheduled for the next release

Original comment by andrew.rapp@gmail.com on 13 Aug 2010 at 3:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This has been fixed in the trunk.

Original comment by andrew.rapp@gmail.com on 20 Oct 2010 at 2:41