Convert string to unique integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aniketkadu2002
    New Member
    • Feb 2009
    • 2

    Convert string to unique integer

    i have an array of string which had size of about 3000

    Each entity in the array is a unique string .

    i would want to convert each of this string into a unique integer so that i can use it to store in a hash table ..

    each string is of the form "rlegrEgabc---supprod-C7M" , and all of them are unique.
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    It's impossible - there are some 2^(7*20) ascii-7 strings of length 20, and only 2^32 integers.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by newb16
      It's impossible - there are some 2^(7*20) ascii-7 strings of length 20, and only 2^32 integers.
      For moderate sized, finit sets of strings minimal perfect hash functions can be constructed. For an example see this link.

      kind regards,

      Jos

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        You can also look for CRC for the string like 16bit or 32 bit CRC

        Raghu

        Comment

        Working...