How do I calculate a good hash code for a list of strings?

后端 未结 11 1580
我寻月下人不归
我寻月下人不归 2020-12-01 02:34

Background:

  • I have a short list of strings.
  • The number of strings is not always the same, but are nearly always of the order of a “handful”
  • I
11条回答
  •  不思量自难忘°
    2020-12-01 03:37

    I hope this is unnecessary, but since you don't mention anything which sounds like you're only using the hashcodes for a first check and then later verifying that the strings are actually equal, I feel the need to warn you:

    Hashcode equality != value equality

    There will be lots of sets of strings which yield the identical hashcode, but won't always be equal.

提交回复
热议问题