Defining the hash of an object as the sum of hashes of its members
Posted
by Space_C0wb0y
on Stack Overflow
See other posts from Stack Overflow
or by Space_C0wb0y
Published on 2010-06-11T10:04:55Z
Indexed on
2010/06/11
10:22 UTC
Read the original article
Hit count: 171
I have a class that represents undirected edges in a graph. Every edge has two members vertex1
and vertex2
representing the vertices it connects. The problem is, that an edge can be specified two directions. My idea was now to define the hash of an edge as the sum of the hashes of its vertices. This way, the direction plays no role anymore, the hash would be the same. Are there any pitfalls with that?
© Stack Overflow or respective owner