Bladeren bron

Reformat Matches class

Philipp Bauch 6 jaren geleden
bovenliggende
commit
faf9fc7f6b
2 gewijzigde bestanden met toevoegingen van 18 en 11 verwijderingen
  1. 17 10
      jplag/src/main/java/jplag/Matches.java
  2. 1 1
      jplag/src/main/java/jplag/Submission.java

+ 17 - 10
jplag/src/main/java/jplag/Matches.java

@@ -4,14 +4,17 @@ package jplag;
  * Minimal class that stores "Match" objects.
  */
 public class Matches {
+
   public Match[] matches;
 
   private int anzahl;
   private final int increment = 20;
-  
+
   public Matches() {
     matches = new Match[10];
-    for (int i=0; i<10; i++) matches[i] = new Match();
+    for (int i = 0; i < 10; i++) {
+      matches[i] = new Match();
+    }
     anzahl = 0;
   }
 
@@ -25,14 +28,16 @@ public class Matches {
       Match[] oldMatches = matches;
       int newCapacity = (oldCapacity + increment);
       if (newCapacity < minCapacity) {
-	newCapacity = minCapacity;
+        newCapacity = minCapacity;
       }
       matches = new Match[newCapacity];
       System.arraycopy(oldMatches, 0, matches, 0, oldCapacity);
-      for (int i=oldCapacity; i<newCapacity; i++)
-	matches[i] = new Match();
+      for (int i = oldCapacity; i < newCapacity; i++) {
+        matches[i] = new Match();
+      }
     }
   }
+
   /*
   public final void addMatch(Match match) {
     for (int i=0; i<anzahl; i++)
@@ -42,19 +47,21 @@ public class Matches {
   }
   */
   public final void addMatch(int startA, int startB, int length) {
-    for (int i=anzahl-1; i>=0; i--) { // starting at the end is better(?)
-      if (matches[i].overlap(startA,startB,length)) return;
-                                      // no overlaps!
+    for (int i = anzahl - 1; i >= 0; i--) { // starting at the end is better(?)
+      if (matches[i].overlap(startA, startB, length)) {
+        return;
+      }
+      // no overlaps!
     }
     ensureCapacity(anzahl + 1);
     //if (matches[anzahl] != null)  // object recycling...
-    matches[anzahl].set(startA,startB,length);
+    matches[anzahl].set(startA, startB, length);
     //else
     //matches[anzahl ] = new Match(startA,startB,length);
     anzahl++;
   }
 
   public final void clear() {
-    anzahl=0;
+    anzahl = 0;
   }
 }

+ 1 - 1
jplag/src/main/java/jplag/Submission.java

@@ -30,7 +30,7 @@ public class Submission implements Comparable<Submission> {
   public List<File> files;
 
   /**
-   * List of tokens that have been parsed from the files this submission contains.
+   * List of tokens that have been parsed from the files this submission consists of.
    * <p>
    * TODO: The name 'Structure' is very generic and should be changed to something more descriptive.
    */