Skip to content

Instantly share code, notes, and snippets.

@zadr
Last active December 13, 2015 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zadr/589016d81b3b0e5fba55 to your computer and use it in GitHub Desktop.
Save zadr/589016d81b3b0e5fba55 to your computer and use it in GitHub Desktop.
internal extension SequenceType where Element: Hashable {
/**
Returns a modified djb hash of all of the elements in a list.
Reference: http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
*/
internal var hashValue: Int {
get {
return reduce(0) { (x, element) -> Int in
return 33 * x ^ element.hashValue
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment