Skip to content

Instantly share code, notes, and snippets.

@busti
Forked from kroovysteph/BucketMap.java
Last active January 24, 2017 16:18
Show Gist options
  • Save busti/8112ba2e5f77548e0eb0730e02ad3b79 to your computer and use it in GitHub Desktop.
Save busti/8112ba2e5f77548e0eb0730e02ad3b79 to your computer and use it in GitHub Desktop.
public int sumAllValues() {
// TODO: implement
int sum = 0;
for (int h=0; h < N; h++) {
for (KeyValue kv = buckets[h]; kv != null; kv = kv.next) {
if (kv.value.matches("^\\-?\\d*\\.?\\d*$")) {
sum += Integer.parseInt(kv.value);
}
}
}
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment