style: enable MemberName in checkstyle (#5193)

* style: enable MemberName in checkstyle

* style: simply uncomment `MemberName`

---------

Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
S. Utkarsh
2024-05-30 02:14:14 +05:30
committed by GitHub
parent d2bfb100b2
commit a6e873deef
17 changed files with 168 additions and 168 deletions

View File

@ -12,21 +12,21 @@ public class HashMapCuckooHashing {
private int tableSize; // size of the hash table
private Integer[] buckets; // array representing the table
private final Integer AVAILABLE;
private final Integer emptySlot;
private int size; // number of elements in the hash table
private int thresh; // threshold for infinite loop checking
/**
* Constructor initializes buckets array, hsize, and creates dummy object
* for AVAILABLE
* for emptySlot
*
* @param tableSize the desired size of the hash map
*/
public HashMapCuckooHashing(int tableSize) {
this.buckets = new Integer[tableSize];
this.tableSize = tableSize;
this.AVAILABLE = Integer.MIN_VALUE;
this.emptySlot = Integer.MIN_VALUE;
this.size = 0;
this.thresh = (int) (Math.log(tableSize) / Math.log(2)) + 2;
}
@ -84,7 +84,7 @@ public class HashMapCuckooHashing {
loopCounter++;
hash = hashFunction1(key);
if ((buckets[hash] == null) || Objects.equals(buckets[hash], AVAILABLE)) {
if ((buckets[hash] == null) || Objects.equals(buckets[hash], emptySlot)) {
buckets[hash] = wrappedInt;
size++;
checkLoadFactor();
@ -95,7 +95,7 @@ public class HashMapCuckooHashing {
buckets[hash] = wrappedInt;
wrappedInt = temp;
hash = hashFunction2(temp);
if (Objects.equals(buckets[hash], AVAILABLE)) {
if (Objects.equals(buckets[hash], emptySlot)) {
buckets[hash] = wrappedInt;
size++;
checkLoadFactor();
@ -124,7 +124,7 @@ public class HashMapCuckooHashing {
public void reHashTableIncreasesTableSize() {
HashMapCuckooHashing newT = new HashMapCuckooHashing(tableSize * 2);
for (int i = 0; i < tableSize; i++) {
if (buckets[i] != null && !Objects.equals(buckets[i], AVAILABLE)) {
if (buckets[i] != null && !Objects.equals(buckets[i], emptySlot)) {
newT.insertKey2HashTable(this.buckets[i]);
}
}
@ -146,14 +146,14 @@ public class HashMapCuckooHashing {
}
if (Objects.equals(buckets[hash], wrappedInt)) {
buckets[hash] = AVAILABLE;
buckets[hash] = emptySlot;
size--;
return;
}
hash = hashFunction2(key);
if (Objects.equals(buckets[hash], wrappedInt)) {
buckets[hash] = AVAILABLE;
buckets[hash] = emptySlot;
size--;
return;
}
@ -165,7 +165,7 @@ public class HashMapCuckooHashing {
*/
public void displayHashtable() {
for (int i = 0; i < tableSize; i++) {
if ((buckets[i] == null) || Objects.equals(buckets[i], AVAILABLE)) {
if ((buckets[i] == null) || Objects.equals(buckets[i], emptySlot)) {
System.out.println("Bucket " + i + ": Empty");
} else {
System.out.println("Bucket " + i + ": " + buckets[i].toString());
@ -229,7 +229,7 @@ public class HashMapCuckooHashing {
public boolean isFull() {
boolean response = true;
for (int i = 0; i < tableSize; i++) {
if (buckets[i] == null || Objects.equals(buckets[i], AVAILABLE)) {
if (buckets[i] == null || Objects.equals(buckets[i], emptySlot)) {
return false;
}
}