Ensure there is capacity in the hash table before attempting to add an entry.

This commit is contained in:
Peter Lawrey
2015-12-17 12:13:49 -06:00
parent bd64095042
commit a07fd3ba3d
7 changed files with 130 additions and 22 deletions
+16
View File
@@ -286,6 +286,22 @@ class Int24Int24MultiMap implements MultiMap {
}
}
public long size() {
long pos = 0;
int size = 0;
for (int count = capacity; count > 0; count--) {
long entry = bytes.readInt48(pos);
pos = step(pos);
if (entry != UNSET_ENTRY)
size++;
}
return size;
}
@Override
public long capacity() {
return capacity;
}
@Override
public DirectBitSet getPositions() {
return positions;