Make sure to set last bucket to null after remove or you could have a memory leak
This commit is contained in:
parent
4e1473a6f0
commit
01893f9678
|
@ -260,6 +260,7 @@ public class Array2DHashSet<T> implements Set<T> {
|
||||||
// shift all elements to the right down one
|
// shift all elements to the right down one
|
||||||
// for (int j=i; j<bucket.length-1; j++) bucket[j] = bucket[j+1];
|
// for (int j=i; j<bucket.length-1; j++) bucket[j] = bucket[j+1];
|
||||||
System.arraycopy(bucket, i+1, bucket, i, bucket.length-i-1);
|
System.arraycopy(bucket, i+1, bucket, i, bucket.length-i-1);
|
||||||
|
bucket[bucket.length - 1] = null;
|
||||||
n--;
|
n--;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue