Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-9938: Make some afw types hashable #17

Merged
merged 2 commits into from Nov 7, 2018
Merged

Conversation

kfindeisen
Copy link
Member

This PR switches Point's existing hash to use std::hash, and adds hash support to all value types in geom (defined as supporting operator==).

This PR requires lsst/utils#65.

return 179;
} else {
return utils::hashCombine(17, _minimum, _maximum);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the magic numbers here are completely arbitrary and just need to be nonzero and deterministic, but even if that's the case I think a code comment would be welcome. That's especially true if they have other useful properties, like being odd numbers.

Copy link
Member Author

@kfindeisen kfindeisen Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel better if they're prime numbers (though I do violate that rule with 42 😉), but yes, they're basically arbitrary. I'll go ahead and add a comment, but I feel like there's too much boilerplate already.

P.S. Actually, the seed need not be deterministic, as long as you only generate it once -- that's how you get salted hashes.

Point and Extent are the only subclasses of CoordinateBase that are
equality-comparable, so they're the only ones that should be hashable,
but this means duplicating the actual hash algorithm between the two
classes. I've also added support for std::hash and unit tests of
hash's behavior.
The affected types are Angle, Box2D, Box2I, and SpherePoint.
@kfindeisen kfindeisen merged commit ef5e32a into master Nov 7, 2018
@kfindeisen kfindeisen deleted the tickets/DM-9938 branch November 7, 2018 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants