4 ms·
Ints are 32 bits and pointers are 64 bits (https://www.ibm.com/docs/en/ibm-mq/9.1?topic=platforms-standard-data-types-unix-linux-windows https://www.ibm.com/doc
by samsaga2 4y ago
Ints are 32 bits and pointers are 64 bits (https://www.ibm.com/docs/en/ibm-mq/9.1?topic=platforms-standard-data-types-unix-linux-windows https://www.ibm.com/docs/en/ibm-mq/9.1?topic=platforms-stand...).
Converting from pointer to int you are truncating the value from 64 bits to 32 (discarding the high 32 bits). You are losing information, so, two different nodes with different pointers addresses could have the same int.
Also, a bool array to store all the visited nodes will be really huge (memory address can have very high numbers).
A better solution is to use a hash table (for ex. std::unordered_map<void*, bool>).