Stream: helpdesk (published)

Topic: Implementing hash for Point type


view this post on Zulip Júlio Hoffimann (Mar 25 2023 at 14:22):

In Meshes.jl we have an implementation of == for Point that simply fallsback to isapprox:

https://github.com/JuliaGeometry/Meshes.jl/blob/b2586c911a3d5f04cb8ea5ceff37eb9bd661b308/src/points.jl#L142-L155

By reading the docs of isequal, I learned that we also need to define hash(::Point, h) so that the isequal behaves properly in Set and Dict, etc.

How should I define the hash function for Point in this context of geometric processing? How do you usually implement hash in general?

view this post on Zulip jar (Mar 25 2023 at 17:30):

https://softwareengineering.stackexchange.com/questions/391100/how-to-implement-float-hashing-with-approximate-equality

view this post on Zulip Júlio Hoffimann (Mar 26 2023 at 12:45):

Very educative thread @jar thanks for sharing. We will probably refactor some ideas in Meshes.jl accordingly.


Last updated: Nov 06 2024 at 04:40 UTC