Aleena Rose-Mathew 6 年之前
父節點
當前提交
8cb9c0edd2
共有 1 個文件被更改,包括 27 次插入26 次删除
  1. 27
    26
      src/main/java/com/zipcodewilmington/arrayutility/ArrayUtility.java

+ 27
- 26
src/main/java/com/zipcodewilmington/arrayutility/ArrayUtility.java 查看文件

@@ -15,32 +15,6 @@ public class ArrayUtility<S> {
15 15
         this.newlist.addAll(Arrays.asList(inputArray));
16 16
         //S[] temp = (S[]) new Object[length];(creating a new generic array)
17 17
     }
18
-    public Integer countDuplicatesInMerge(S[] inputArray, S valueToEvaluate ) {
19
-        Integer count=0;
20
-        newlist.addAll(Arrays.asList(inputArray));
21
-        for (S element : newlist) {
22
-            if(element.equals(valueToEvaluate))
23
-            {
24
-                count++;
25
-            }
26
-        }
27
-        return count;
28
-    }
29
-
30
-    public S getMostCommonFromMerge(S[] inputArray)
31
-    {
32
-        S mostcommonElement=inputArray[0];
33
-        int mostcommonElementOccurences=0;
34
-        for(S element :newlist)
35
-        {
36
-            if(getNumberOfOccurrences(element)>mostcommonElementOccurences)
37
-            {
38
-                mostcommonElement=element;
39
-                mostcommonElementOccurences=getNumberOfOccurrences(element);
40
-            }
41
-        }
42
-        return mostcommonElement;
43
-    }
44 18
     public int getNumberOfOccurrences(S valueToEvaluate)
45 19
     {
46 20
         int countOccurence=0;
@@ -71,4 +45,31 @@ public class ArrayUtility<S> {
71 45
 
72 46
     }
73 47
 
48
+    public Integer countDuplicatesInMerge(S[] inputArray, S valueToEvaluate ) {
49
+        Integer count=0;
50
+        newlist.addAll(Arrays.asList(inputArray));
51
+        for (S element : newlist) {
52
+            if(element.equals(valueToEvaluate))
53
+            {
54
+                count++;
55
+            }
56
+        }
57
+        return count;
58
+    }
59
+
60
+    public S getMostCommonFromMerge(S[] inputArray)
61
+    {
62
+        S mostcommonElement=inputArray[0];
63
+        int mostcommonElementOccurences=0;
64
+        for(S element :newlist)
65
+        {
66
+            if(getNumberOfOccurrences(element)>mostcommonElementOccurences)
67
+            {
68
+                mostcommonElement=element;
69
+                mostcommonElementOccurences=getNumberOfOccurrences(element);
70
+            }
71
+        }
72
+        return mostcommonElement;
73
+    }
74
+
74 75
 }