We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 197403b commit 86ff19dCopy full SHA for 86ff19d
src/dataStructures/hashSet/openAddressing/HashSet.java
@@ -57,6 +57,10 @@ public HashSet() {
57
* element
58
*/
59
public boolean add(T element) {
60
+ if (isLoadFactorExceeded()) {
61
+ resize(this.capacity() * 2); // Resize to double the capacity.
62
+ }
63
+
64
int bucketIndex = this.linearProbe(element);
65
if (!this.isEmptyBucket(bucketIndex)) { // probe function returns the index of an empty bucket or the index containing the element.
66
return false; // Duplicate elements are not added to the set.
0 commit comments