Last active
December 7, 2017 00:52
-
-
Save aarohmankad/194ea6e5e98cd845443aa011a8a6269e to your computer and use it in GitHub Desktop.
A good example showing why to leave comments in your code
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
int hash(string input) { | |
int output = 5381; | |
// Less collisions than simply adding ASCII characters of value | |
// simple method: hash("tab") = hash("bat") | |
// this method: hash("tab") != hash("bat") | |
for (char c : input) { | |
output += (output << 5) + c; | |
} | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment