Quellcode durchsuchen

Finished Count Duplicates In Merge Method

CWinarski vor 6 Jahren
Ursprung
Commit
d6a6e62dab

+ 37
- 1
src/main/java/com/zipcodewilmington/arrayutility/ArrayUtility.java Datei anzeigen

@@ -1,7 +1,43 @@
1 1
 package com.zipcodewilmington.arrayutility;
2 2
 
3
+import java.util.Arrays;
4
+
3 5
 /**
4 6
  * Created by leon on 3/6/18.
5 7
  */
6
-public class ArrayUtility {
8
+public class ArrayUtility<T> {
9
+
10
+    public T[] inputArray;
11
+    public T[] mergedArray;
12
+
13
+    public ArrayUtility(T[] inputArray){
14
+        this.inputArray = inputArray;
15
+    }
16
+
17
+    public T getMostCommonFromMerge(T[] arrayToMerge) {
18
+     this.mergedArray = Arrays.copyOf(this.inputArray, this.inputArray.length + arrayToMerge.length);
19
+     System.arraycopy(arrayToMerge, 0, mergedArray, mergedArray.length - arrayToMerge.length, arrayToMerge.length);
20
+     return null;
21
+    }
22
+
23
+    public Integer countDuplicatesInMerge(T[] arrayToMerge, T valueToEvaluate) {
24
+     this.mergedArray = Arrays.copyOf(this.inputArray, this.inputArray.length + arrayToMerge.length);
25
+      System.arraycopy(arrayToMerge, 0, mergedArray, mergedArray.length - arrayToMerge.length, arrayToMerge.length);
26
+       Integer count = 0;
27
+       for (T t : this.mergedArray){
28
+           if (t == valueToEvaluate){
29
+               count++;
30
+           }
31
+       }
32
+        return count;
33
+    }
34
+
35
+    public Integer getNumberOfOccurrences(T valueToEvaluate) {
36
+        return null;
37
+    }
38
+
39
+    public T[] removeValue(T valueToRemove) {
40
+           return null;
41
+    }
42
+
7 43
 }

+ 1
- 1
src/test/java/com/zipcodewilmington/arrayutility/RemoveValueTest.java Datei anzeigen

@@ -1,6 +1,6 @@
1 1
 package com.zipcodewilmington.arrayutility;
2 2
 
3
-import com.zipcodewilmington.UnitTestingUtils;
3
+//import com.zipcodewilmington.UnitTestingUtils;
4 4
 import org.junit.Test;
5 5
 
6 6
 /**