ID Overlap checking algorithm
An answer to this question on Stack Overflow.
Question
Example, the server has these ids:
aaaa, aaaa - 1 , aaaa - 2 , bbbb
If the client sign in, the server check client's algorithm
If the client's id is aaaa, server make client's id aaaa - 3
If the client's id is bbbb, server make client's id bbbb -1
How can i do that?
Answer
- Make a hash table that stores the number of times an id has been seen.
- Check the hash table to see if an id has been seen:
- If so, increment and return the number
- If not, make a new entry and set to 0.