Conversation
Implement a specialization of `std::hash<YAML::Node>` so that nodes can be used in unordered associative containers.
jbeder
left a comment
There was a problem hiding this comment.
What are the semantics of this hash?
|
As you can see from the implementation it basically boils down to looking at the location of the node in memory. If two nodes point to the same memory location then they produce the same hash digest. The idea here is that, as mentioned in #265, there are situations in which you may want to be able to use the nodes themselves as indices into a data structure when processing the graph that the YAML represents. |
|
So there'll still be times when the nodes are the 'same', but don't hash to
the same value?
…On Mon, Aug 5, 2019 at 1:58 AM Fredrik Appelros ***@***.***> wrote:
As you can see from the implementation it basically boils down to looking
at the location of the node in memory. If two nodes point to the same
memory location then they produce the same hash digest.
The idea here is that, as mentioned in #265
<#265>, there are situations in
which you may want to be able to use the nodes themselves as indices into a
data structure when processing the graph that the YAML represents.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#715?email_source=notifications&email_token=AAICUBWLIMANY6H7MHTT3WTQC7FQRA5CNFSM4IEAOMU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3Q35AA#issuecomment-518110848>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAICUBWSFPOU2QXRSHQKG3TQC7FQRANCNFSM4IEAOMUQ>
.
|
|
I guess that depends on what your definition of "same" is. If I have understood it correctly this is based on the same principle as the existing equality operator that is used for nodes as can be seen here. |
|
Just a friendly ping to see if we could resume this discussion. :) |
|
Is there anything else that I can do to move this along? |
|
If I create two nodes, separately, with the same content, would they get the same hash? The |
Implement a specialization of
std::hash<YAML::Node>so that nodes can be used in unordered associative containers.This would resolve parts of what is mentioned in #265.