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

@@ -17,7 +17,7 @@ import java.util.Map;
*/
class GCounter {
private final Map<Integer, Integer> P;
private final Map<Integer, Integer> counterMap;
private final int myId;
private final int n;
@@ -29,10 +29,10 @@ class GCounter {
GCounter(int myId, int n) {
this.myId = myId;
this.n = n;
this.P = new HashMap<>();
this.counterMap = new HashMap<>();
for (int i = 0; i < n; i++) {
P.put(i, 0);
counterMap.put(i, 0);
}
}
@@ -40,7 +40,7 @@ class GCounter {
* Increments the counter for the current node.
*/
public void increment() {
P.put(myId, P.get(myId) + 1);
counterMap.put(myId, counterMap.get(myId) + 1);
}
/**
@@ -50,7 +50,7 @@ class GCounter {
*/
public int value() {
int sum = 0;
for (int v : P.values()) {
for (int v : counterMap.values()) {
sum += v;
}
return sum;
@@ -64,7 +64,7 @@ class GCounter {
*/
public boolean compare(GCounter other) {
for (int i = 0; i < n; i++) {
if (this.P.get(i) > other.P.get(i)) {
if (this.counterMap.get(i) > other.counterMap.get(i)) {
return false;
}
}
@@ -78,7 +78,7 @@ class GCounter {
*/
public void merge(GCounter other) {
for (int i = 0; i < n; i++) {
this.P.put(i, Math.max(this.P.get(i), other.P.get(i)));
this.counterMap.put(i, Math.max(this.counterMap.get(i), other.counterMap.get(i)));
}
}
}

View File

@@ -17,8 +17,8 @@ import java.util.Map;
*/
class PNCounter {
private final Map<Integer, Integer> P;
private final Map<Integer, Integer> N;
private final Map<Integer, Integer> pCounter;
private final Map<Integer, Integer> nCounter;
private final int myId;
private final int n;
@@ -31,12 +31,12 @@ class PNCounter {
PNCounter(int myId, int n) {
this.myId = myId;
this.n = n;
this.P = new HashMap<>();
this.N = new HashMap<>();
this.pCounter = new HashMap<>();
this.nCounter = new HashMap<>();
for (int i = 0; i < n; i++) {
P.put(i, 0);
N.put(i, 0);
pCounter.put(i, 0);
nCounter.put(i, 0);
}
}
@@ -44,14 +44,14 @@ class PNCounter {
* Increments the increment counter for the current node.
*/
public void increment() {
P.put(myId, P.get(myId) + 1);
pCounter.put(myId, pCounter.get(myId) + 1);
}
/**
* Increments the decrement counter for the current node.
*/
public void decrement() {
N.put(myId, N.get(myId) + 1);
nCounter.put(myId, nCounter.get(myId) + 1);
}
/**
@@ -60,8 +60,8 @@ class PNCounter {
* @return The total value of the counter.
*/
public int value() {
int sumP = P.values().stream().mapToInt(Integer::intValue).sum();
int sumN = N.values().stream().mapToInt(Integer::intValue).sum();
int sumP = pCounter.values().stream().mapToInt(Integer::intValue).sum();
int sumN = nCounter.values().stream().mapToInt(Integer::intValue).sum();
return sumP - sumN;
}
@@ -76,7 +76,7 @@ class PNCounter {
throw new IllegalArgumentException("Cannot compare PN-Counters with different number of nodes");
}
for (int i = 0; i < n; i++) {
if (this.P.get(i) > other.P.get(i) && this.N.get(i) > other.N.get(i)) {
if (this.pCounter.get(i) > other.pCounter.get(i) && this.nCounter.get(i) > other.nCounter.get(i)) {
return false;
}
}
@@ -93,8 +93,8 @@ class PNCounter {
throw new IllegalArgumentException("Cannot merge PN-Counters with different number of nodes");
}
for (int i = 0; i < n; i++) {
this.P.put(i, Math.max(this.P.get(i), other.P.get(i)));
this.N.put(i, Math.max(this.N.get(i), other.N.get(i)));
this.pCounter.put(i, Math.max(this.pCounter.get(i), other.pCounter.get(i)));
this.nCounter.put(i, Math.max(this.nCounter.get(i), other.nCounter.get(i)));
}
}
}