python - Is it a good idea to generate and store a random number as a hash value for my class? -


i have class wraps list, , lists apparently can't have hash values. idea generate random number , store hash value.

not idea. general contract of hash code if object equals object b, a.hashcode() equals b.hashcode(). you're proposing wont hold.

you try using

  • list length hash code
  • hash code of first item in list hashcode
  • sum of hashcodes of items hashcode

or else along these lines.


Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

java - Getting corefrences with Standard corenlp package -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -