Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmrbastard

Posted 22 November 2012 - 06:33 AM

You probably don't want a 'real' hash function for this - just associate each string with an integer. For example you could start at zero increment for each string added, putting them as key and value in an std::map. Things get more complicated if you want to remove strings and reuse integers, but you probably won't need to.

Edit: turns out this is called string interning. Thanks Hodgman!

#1mrbastard

Posted 22 November 2012 - 06:26 AM

You probably don't want a 'real' hash function for this - just associate each string with an integer. For example you could start at zero increment for each string added, putting them as key and value in an std::map. Things get more complicated if you want to remove strings and reuse integers, but you probably won't need to.

PARTNERS