0
i want to generate unique id in c. what should i do?
.
3 Réponses
+ 1
you could generate a random string , then use a hashmap to cache the result. if you generate a string already in cache you throw away the result & regenerate to make sure its unique. If it is unique? Store it in cache and return it.
advantage is hashmap lookup time is 0(1) best case , so its as fast as accessing array element.
+ 1
can i ask. what is id, a unique string or unique number??
0
string