| 54 | } |
| 55 | |
| 56 | uint32_t BitDifference(Address a, Address b) |
| 57 | { |
| 58 | // Implements the Hamming Distance algorithm. |
| 59 | // https://en.wikipedia.org/wiki/Hamming_distance |
| 60 | uint32_t difference = 0; |
| 61 | for (uint32_t i = 0; i < (sizeof(a.m_address) / sizeof(uint32_t)); ++i) |
| 62 | { |
| 63 | uint32_t current = a.m_address[i] ^ b.m_address[i]; |
| 64 | while (current != 0) |
| 65 | { |
| 66 | difference += current % 2; |
| 67 | current = current >> 1; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | return difference; |
| 72 | } |
| 73 | |
| 74 | Result Initialize() |
| 75 | { |
no outgoing calls