I have an array of strings that are questions, like "How old are you?", "What's your home town?"
These strings are mostly unique, there are no repeating strings. Now I need an advice on how to convert every single string to a unique number ID, like 1242, 2983, and so on.
But these numbers shouldn't be just numbers showing the place of strings in the array, because array can have different number of strings. I need some algorithm to make sure I always have the same number for a string if I pass it to the ID generating function at any moment.
It's not a problem if occasionally ID's repeat, but if not too often, because I am not going to use these ID's to address the strings from the DB, or anywhere. These are just numbers that will help me to identify them for representation.
Please advise, from where I should start and probably the logic of how to handle it.
Aucun commentaire:
Enregistrer un commentaire