Quick question. If we have `void
` how can we translate it to `int`.For example this:
`static void dfs(SccGraph graph, LinkedStack* stack, bool* visited, void* v)`
I need to mark `v` as visited but how can I quickly convert `void` to `int` so I can mark `visited[(int) v] = true`
I can convert `void` to `int` with a cast but then I need to make sure the size of the `visited` array is prime and not any `n`. Not sure what is the right way to do this.
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>).