| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,7 +111,7 @@ | |||
| 111 | 111 | <module name="ConstantName"/> | |
| 112 | 112 | <module name="LocalFinalVariableName"/> | |
| 113 | 113 | <module name="LocalVariableName"/> | |
| 114 | - <!-- TODO <module name="MemberName"/> --> | ||
| 114 | + <module name="MemberName"/> | ||
| 115 | 115 | <module name="MethodName"/> | |
| 116 | 116 | <module name="PackageName"/> | |
| 117 | 117 | <!-- TODO <module name="ParameterName"/> --> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | public class Blowfish { | |
| 12 | 12 | ||
| 13 | 13 | // Initializing substitution boxes | |
| 14 | - String[][] S = { | ||
| 14 | + String[][] sBox = { | ||
| 15 | 15 | { | |
| 16 | 16 | "d1310ba6", | |
| 17 | 17 | "98dfb5ac", | |
@@ -1047,7 +1047,7 @@ public class Blowfish { | |||
| 1047 | 1047 | }; | |
| 1048 | 1048 | ||
| 1049 | 1049 | // Initializing subkeys with digits of pi | |
| 1050 | - String[] P = { | ||
| 1050 | + String[] subKeys = { | ||
| 1051 | 1051 | "243f6a88", | |
| 1052 | 1052 | "85a308d3", | |
| 1053 | 1053 | "13198a2e", | |
@@ -1154,7 +1154,7 @@ private String f(String plainText) { | |||
| 1154 | 1154 | for (int i = 0; i < 8; i += 2) { | |
| 1155 | 1155 | // column number for S-box is a 8-bit value | |
| 1156 | 1156 | long col = Long.parseUnsignedLong(hexToBin(plainText.substring(i, i + 2)), 2); | |
| 1157 | - a[i / 2] = S[i / 2][(int) col]; | ||
| 1157 | + a[i / 2] = sBox[i / 2][(int) col]; | ||
| 1158 | 1158 | } | |
| 1159 | 1159 | ans = addBin(a[0], a[1]); | |
| 1160 | 1160 | ans = xor(ans, a[2]); | |
@@ -1165,9 +1165,9 @@ private String f(String plainText) { | |||
| 1165 | 1165 | // generate subkeys | |
| 1166 | 1166 | private void keyGenerate(String key) { | |
| 1167 | 1167 | int j = 0; | |
| 1168 | - for (int i = 0; i < P.length; i++) { | ||
| 1168 | + for (int i = 0; i < subKeys.length; i++) { | ||
| 1169 | 1169 | // XOR-ing 32-bit parts of the key with initial subkeys | |
| 1170 | - P[i] = xor(P[i], key.substring(j, j + 8)); | ||
| 1170 | + subKeys[i] = xor(subKeys[i], key.substring(j, j + 8)); | ||
| 1171 | 1171 | ||
| 1172 | 1172 | j = (j + 8) % key.length(); | |
| 1173 | 1173 | } | |
@@ -1179,7 +1179,7 @@ private String round(int time, String plainText) { | |||
| 1179 | 1179 | String right; | |
| 1180 | 1180 | left = plainText.substring(0, 8); | |
| 1181 | 1181 | right = plainText.substring(8, 16); | |
| 1182 | - left = xor(left, P[time]); | ||
| 1182 | + left = xor(left, subKeys[time]); | ||
| 1183 | 1183 | ||
| 1184 | 1184 | // output from F function | |
| 1185 | 1185 | String fOut = f(left); | |
@@ -1207,8 +1207,8 @@ String encrypt(String plainText, String key) { | |||
| 1207 | 1207 | // postprocessing | |
| 1208 | 1208 | String right = plainText.substring(0, 8); | |
| 1209 | 1209 | String left = plainText.substring(8, 16); | |
| 1210 | - right = xor(right, P[16]); | ||
| 1211 | - left = xor(left, P[17]); | ||
| 1210 | + right = xor(right, subKeys[16]); | ||
| 1211 | + left = xor(left, subKeys[17]); | ||
| 1212 | 1212 | return left + right; | |
| 1213 | 1213 | } | |
| 1214 | 1214 | ||
@@ -1229,8 +1229,8 @@ String decrypt(String cipherText, String key) { | |||
| 1229 | 1229 | // postprocessing | |
| 1230 | 1230 | String right = cipherText.substring(0, 8); | |
| 1231 | 1231 | String left = cipherText.substring(8, 16); | |
| 1232 | - right = xor(right, P[1]); | ||
| 1233 | - left = xor(left, P[0]); | ||
| 1232 | + right = xor(right, subKeys[1]); | ||
| 1233 | + left = xor(left, subKeys[0]); | ||
| 1234 | 1234 | return left + right; | |
| 1235 | 1235 | } | |
| 1236 | 1236 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | // Hex [0-9],[A-F] -> Binary [0,1] | |
| 4 | 4 | public class HexaDecimalToBinary { | |
| 5 | 5 | ||
| 6 | - private final int LONG_BITS = 8; | ||
| 6 | + private final int longBits = 8; | ||
| 7 | 7 | ||
| 8 | 8 | public String convert(String numHex) { | |
| 9 | 9 | // String a HexaDecimal: | |
@@ -15,7 +15,7 @@ public String convert(String numHex) { | |||
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | 17 | public String completeDigits(String binNum) { | |
| 18 | - for (int i = binNum.length(); i < LONG_BITS; i++) { | ||
| 18 | + for (int i = binNum.length(); i < longBits; i++) { | ||
| 19 | 19 | binNum = "0" + binNum; | |
| 20 | 20 | } | |
| 21 | 21 | return binNum; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ | |||
| 17 | 17 | */ | |
| 18 | 18 | ||
| 19 | 19 | class GCounter { | |
| 20 | - private final Map<Integer, Integer> P; | ||
| 20 | + private final Map<Integer, Integer> counterMap; | ||
| 21 | 21 | private final int myId; | |
| 22 | 22 | private final int n; | |
| 23 | 23 | ||
@@ -29,18 +29,18 @@ class GCounter { | |||
| 29 | 29 | GCounter(int myId, int n) { | |
| 30 | 30 | this.myId = myId; | |
| 31 | 31 | this.n = n; | |
| 32 | - this.P = new HashMap<>(); | ||
| 32 | + this.counterMap = new HashMap<>(); | ||
| 33 | 33 | ||
| 34 | 34 | for (int i = 0; i < n; i++) { | |
| 35 | - P.put(i, 0); | ||
| 35 | + counterMap.put(i, 0); | ||
| 36 | 36 | } | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | /** | |
| 40 | 40 | * Increments the counter for the current node. | |
| 41 | 41 | */ | |
| 42 | 42 | public void increment() { | |
| 43 | - P.put(myId, P.get(myId) + 1); | ||
| 43 | + counterMap.put(myId, counterMap.get(myId) + 1); | ||
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | 46 | /** | |
@@ -50,7 +50,7 @@ public void increment() { | |||
| 50 | 50 | */ | |
| 51 | 51 | public int value() { | |
| 52 | 52 | int sum = 0; | |
| 53 | - for (int v : P.values()) { | ||
| 53 | + for (int v : counterMap.values()) { | ||
| 54 | 54 | sum += v; | |
| 55 | 55 | } | |
| 56 | 56 | return sum; | |
@@ -64,7 +64,7 @@ public int value() { | |||
| 64 | 64 | */ | |
| 65 | 65 | public boolean compare(GCounter other) { | |
| 66 | 66 | for (int i = 0; i < n; i++) { | |
| 67 | - if (this.P.get(i) > other.P.get(i)) { | ||
| 67 | + if (this.counterMap.get(i) > other.counterMap.get(i)) { | ||
| 68 | 68 | return false; | |
| 69 | 69 | } | |
| 70 | 70 | } | |
@@ -78,7 +78,7 @@ public boolean compare(GCounter other) { | |||
| 78 | 78 | */ | |
| 79 | 79 | public void merge(GCounter other) { | |
| 80 | 80 | for (int i = 0; i < n; i++) { | |
| 81 | - this.P.put(i, Math.max(this.P.get(i), other.P.get(i))); | ||
| 81 | + this.counterMap.put(i, Math.max(this.counterMap.get(i), other.counterMap.get(i))); | ||
| 82 | 82 | } | |
| 83 | 83 | } | |
| 84 | 84 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,8 +17,8 @@ | |||
| 17 | 17 | */ | |
| 18 | 18 | ||
| 19 | 19 | class PNCounter { | |
| 20 | - private final Map<Integer, Integer> P; | ||
| 21 | - private final Map<Integer, Integer> N; | ||
| 20 | + private final Map<Integer, Integer> pCounter; | ||
| 21 | + private final Map<Integer, Integer> nCounter; | ||
| 22 | 22 | private final int myId; | |
| 23 | 23 | private final int n; | |
| 24 | 24 | ||
@@ -31,27 +31,27 @@ class PNCounter { | |||
| 31 | 31 | PNCounter(int myId, int n) { | |
| 32 | 32 | this.myId = myId; | |
| 33 | 33 | this.n = n; | |
| 34 | - this.P = new HashMap<>(); | ||
| 35 | - this.N = new HashMap<>(); | ||
| 34 | + this.pCounter = new HashMap<>(); | ||
| 35 | + this.nCounter = new HashMap<>(); | ||
| 36 | 36 | ||
| 37 | 37 | for (int i = 0; i < n; i++) { | |
| 38 | - P.put(i, 0); | ||
| 39 | - N.put(i, 0); | ||
| 38 | + pCounter.put(i, 0); | ||
| 39 | + nCounter.put(i, 0); | ||
| 40 | 40 | } | |
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | /** | |
| 44 | 44 | * Increments the increment counter for the current node. | |
| 45 | 45 | */ | |
| 46 | 46 | public void increment() { | |
| 47 | - P.put(myId, P.get(myId) + 1); | ||
| 47 | + pCounter.put(myId, pCounter.get(myId) + 1); | ||
| 48 | 48 | } | |
| 49 | 49 | ||
| 50 | 50 | /** | |
| 51 | 51 | * Increments the decrement counter for the current node. | |
| 52 | 52 | */ | |
| 53 | 53 | public void decrement() { | |
| 54 | - N.put(myId, N.get(myId) + 1); | ||
| 54 | + nCounter.put(myId, nCounter.get(myId) + 1); | ||
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | 57 | /** | |
@@ -60,8 +60,8 @@ public void decrement() { | |||
| 60 | 60 | * @return The total value of the counter. | |
| 61 | 61 | */ | |
| 62 | 62 | public int value() { | |
| 63 | - int sumP = P.values().stream().mapToInt(Integer::intValue).sum(); | ||
| 64 | - int sumN = N.values().stream().mapToInt(Integer::intValue).sum(); | ||
| 63 | + int sumP = pCounter.values().stream().mapToInt(Integer::intValue).sum(); | ||
| 64 | + int sumN = nCounter.values().stream().mapToInt(Integer::intValue).sum(); | ||
| 65 | 65 | return sumP - sumN; | |
| 66 | 66 | } | |
| 67 | 67 | ||
@@ -76,7 +76,7 @@ public boolean compare(PNCounter other) { | |||
| 76 | 76 | throw new IllegalArgumentException("Cannot compare PN-Counters with different number of nodes"); | |
| 77 | 77 | } | |
| 78 | 78 | for (int i = 0; i < n; i++) { | |
| 79 | - if (this.P.get(i) > other.P.get(i) && this.N.get(i) > other.N.get(i)) { | ||
| 79 | + if (this.pCounter.get(i) > other.pCounter.get(i) && this.nCounter.get(i) > other.nCounter.get(i)) { | ||
| 80 | 80 | return false; | |
| 81 | 81 | } | |
| 82 | 82 | } | |
@@ -93,8 +93,8 @@ public void merge(PNCounter other) { | |||
| 93 | 93 | throw new IllegalArgumentException("Cannot merge PN-Counters with different number of nodes"); | |
| 94 | 94 | } | |
| 95 | 95 | for (int i = 0; i < n; i++) { | |
| 96 | - this.P.put(i, Math.max(this.P.get(i), other.P.get(i))); | ||
| 97 | - this.N.put(i, Math.max(this.N.get(i), other.N.get(i))); | ||
| 96 | + this.pCounter.put(i, Math.max(this.pCounter.get(i), other.pCounter.get(i))); | ||
| 97 | + this.nCounter.put(i, Math.max(this.nCounter.get(i), other.nCounter.get(i))); | ||
| 98 | 98 | } | |
| 99 | 99 | } | |
| 100 | 100 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,12 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | 5 | public class FloydWarshall { | |
| 6 | 6 | ||
| 7 | - private int[][] DistanceMatrix; | ||
| 7 | + private int[][] distanceMatrix; | ||
| 8 | 8 | private int numberofvertices; // number of vertices in the graph | |
| 9 | 9 | public static final int INFINITY = 999; | |
| 10 | 10 | ||
| 11 | 11 | public FloydWarshall(int numberofvertices) { | |
| 12 | - DistanceMatrix = new int[numberofvertices + 1][numberofvertices + 1]; // stores the value of distance from all the possible path form the source | ||
| 12 | + distanceMatrix = new int[numberofvertices + 1][numberofvertices + 1]; // stores the value of distance from all the possible path form the source | ||
| 13 | 13 | // vertex to destination vertex | |
| 14 | 14 | // The matrix is initialized with 0's by default | |
| 15 | 15 | this.numberofvertices = numberofvertices; | |
@@ -18,17 +18,17 @@ public FloydWarshall(int numberofvertices) { | |||
| 18 | 18 | public void floydwarshall(int[][] AdjacencyMatrix) { // calculates all the distances from source to destination vertex | |
| 19 | 19 | for (int source = 1; source <= numberofvertices; source++) { | |
| 20 | 20 | for (int destination = 1; destination <= numberofvertices; destination++) { | |
| 21 | - DistanceMatrix[source][destination] = AdjacencyMatrix[source][destination]; | ||
| 21 | + distanceMatrix[source][destination] = AdjacencyMatrix[source][destination]; | ||
| 22 | 22 | } | |
| 23 | 23 | } | |
| 24 | 24 | for (int intermediate = 1; intermediate <= numberofvertices; intermediate++) { | |
| 25 | 25 | for (int source = 1; source <= numberofvertices; source++) { | |
| 26 | 26 | for (int destination = 1; destination <= numberofvertices; destination++) { | |
| 27 | - if (DistanceMatrix[source][intermediate] + DistanceMatrix[intermediate][destination] < DistanceMatrix[source][destination]) { // calculated distance it get replaced as | ||
| 27 | + if (distanceMatrix[source][intermediate] + distanceMatrix[intermediate][destination] < distanceMatrix[source][destination]) { // calculated distance it get replaced as | ||
| 28 | 28 | // new shortest distance // if the new | |
| 29 | 29 | // distance calculated is less then the | |
| 30 | 30 | // earlier shortest | |
| 31 | - DistanceMatrix[source][destination] = DistanceMatrix[source][intermediate] + DistanceMatrix[intermediate][destination]; | ||
| 31 | + distanceMatrix[source][destination] = distanceMatrix[source][intermediate] + distanceMatrix[intermediate][destination]; | ||
| 32 | 32 | } | |
| 33 | 33 | } | |
| 34 | 34 | } | |
@@ -40,7 +40,7 @@ public void floydwarshall(int[][] AdjacencyMatrix) { // calculates all the dista | |||
| 40 | 40 | for (int source = 1; source <= numberofvertices; source++) { | |
| 41 | 41 | System.out.print(source + "\t"); | |
| 42 | 42 | for (int destination = 1; destination <= numberofvertices; destination++) { | |
| 43 | - System.out.print(DistanceMatrix[source][destination] + "\t"); | ||
| 43 | + System.out.print(distanceMatrix[source][destination] + "\t"); | ||
| 44 | 44 | } | |
| 45 | 45 | System.out.println(); | |
| 46 | 46 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | */ | |
| 9 | 9 | public class HamiltonianCycle { | |
| 10 | 10 | ||
| 11 | - private int V; | ||
| 11 | + private int vertex; | ||
| 12 | 12 | private int pathCount; | |
| 13 | 13 | private int[] cycle; | |
| 14 | 14 | private int[][] graph; | |
@@ -22,8 +22,8 @@ public class HamiltonianCycle { | |||
| 22 | 22 | * else returns 1D array with value -1. | |
| 23 | 23 | */ | |
| 24 | 24 | public int[] findHamiltonianCycle(int[][] graph) { | |
| 25 | - this.V = graph.length; | ||
| 26 | - this.cycle = new int[this.V + 1]; | ||
| 25 | + this.vertex = graph.length; | ||
| 26 | + this.cycle = new int[this.vertex + 1]; | ||
| 27 | 27 | ||
| 28 | 28 | // Initialize path array with -1 value | |
| 29 | 29 | for (int i = 0; i < this.cycle.length; i++) { | |
@@ -53,17 +53,17 @@ public int[] findHamiltonianCycle(int[][] graph) { | |||
| 53 | 53 | * @returns true if path is found false otherwise | |
| 54 | 54 | */ | |
| 55 | 55 | public boolean isPathFound(int vertex) { | |
| 56 | - boolean isLastVertexConnectedToStart = this.graph[vertex][0] == 1 && this.pathCount == this.V; | ||
| 56 | + boolean isLastVertexConnectedToStart = this.graph[vertex][0] == 1 && this.pathCount == this.vertex; | ||
| 57 | 57 | if (isLastVertexConnectedToStart) { | |
| 58 | 58 | return true; | |
| 59 | 59 | } | |
| 60 | 60 | ||
| 61 | 61 | /** all vertices selected but last vertex not linked to 0 **/ | |
| 62 | - if (this.pathCount == this.V) { | ||
| 62 | + if (this.pathCount == this.vertex) { | ||
| 63 | 63 | return false; | |
| 64 | 64 | } | |
| 65 | 65 | ||
| 66 | - for (int v = 0; v < this.V; v++) { | ||
| 66 | + for (int v = 0; v < this.vertex; v++) { | ||
| 67 | 67 | /** if connected **/ | |
| 68 | 68 | if (this.graph[vertex][v] == 1) { | |
| 69 | 69 | /** add to path **/ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments