Skip to content

Commit 4d53774

Browse files
committed
chore: remove occurence of 'this' for consistency
1 parent b02a30c commit 4d53774

File tree

1 file changed

+7
-7
lines changed
  • src/main/java/dataStructures/hashSet/openAddressing

1 file changed

+7
-7
lines changed

src/main/java/dataStructures/hashSet/openAddressing/HashSet.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public boolean contains(T element) {
165165
* @return true if this HashSet is empty, false otherwise.
166166
*/
167167
public boolean isEmpty() {
168-
return this.size() == 0;
168+
return size() == 0;
169169
}
170170

171171
/**
@@ -174,7 +174,7 @@ public boolean isEmpty() {
174174
* @return the number of elements present in this HashSet.
175175
*/
176176
public int size() {
177-
return this.size;
177+
return size;
178178
}
179179

180180
/**
@@ -195,7 +195,7 @@ public List<T> toList() {
195195
* @return the number of buckets of this HashSet.
196196
*/
197197
public int capacity() {
198-
return this.buckets.length; // returns the number of buckets.
198+
return buckets.length; // returns the number of buckets.
199199
}
200200

201201
/**
@@ -252,7 +252,7 @@ private int linearProbe(int hash, int collisions) {
252252
* @return true if the bucket at the given index contains no element, false otherwise.
253253
*/
254254
private boolean isEmptyBucket(int bucketIndex) {
255-
return this.isNullBucket(bucketIndex) || this.isTombstoneBucket(bucketIndex);
255+
return this.isNullBucket(bucketIndex) || isTombstoneBucket(bucketIndex);
256256
}
257257

258258
/**
@@ -287,14 +287,14 @@ private boolean isTombstoneBucket(int bucketIndex) {
287287
*/
288288
private void resize(int newCapacity) {
289289
// creates a temporary reference to the original bucket
290-
T[] temp = this.buckets;
290+
T[] temp = buckets;
291291

292292
// Safe cast because the only way to add elements into this HashSet is through the add method, which
293293
// only takes in elements of type T.
294294
@SuppressWarnings("unchecked")
295295
T[] newBuckets = (T[]) new Object[newCapacity];
296-
this.buckets = newBuckets;
297-
this.size = 0;
296+
buckets = newBuckets;
297+
size = 0;
298298

299299
// re-hashes every element and re-insert into the newly created buckets.
300300
Arrays.stream(temp)

0 commit comments

Comments
 (0)