Fixed recent found bugs
-Fixed: addAll with non Specific Collections was crashing lists. -Fixed/Refactor: Clear and trim implementation was all over the place -Fixed: Wrappers toString/hashCode/equals function wasn't implemented -Added: Tests for addAll bug -Refactor: Did small code style cleanups as I was fixing bugs.
This commit is contained in:
+7
-4
@@ -312,14 +312,17 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
||||
|
||||
@Override
|
||||
public void clearAndTrim(int size) {
|
||||
if(nullIndex <= size) {
|
||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||
if(size >= request) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
nullIndex = size;
|
||||
mask = nullIndex - 1;
|
||||
nullIndex = request;
|
||||
mask = request-1;
|
||||
maxFill = Math.min((int)Math.ceil(nullIndex * loadFactor), nullIndex - 1);
|
||||
keys = NEW_KEY_ARRAY(nullIndex + 1);
|
||||
keys = NEW_KEY_ARRAY(request + 1);
|
||||
this.size = 0;
|
||||
containsNull = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user