Created
June 4, 2014 13:12
-
-
Save damirstuhec/00749c1ff006667d0e16 to your computer and use it in GitHub Desktop.
NSString category for computing hash with modulo operation
This file contains hidden or 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
- (NSInteger)hashWithModulo:(NSInteger)modulo | |
{ | |
int i, sum = 0; | |
for (i = 0; i < self.length; i++) | |
{ | |
sum += [self characterAtIndex:i]; | |
} | |
return (sum % modulo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment