Last active
December 13, 2015 00:10
-
-
Save zadr/589016d81b3b0e5fba55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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