Bläddra i källkod

completed dupes

mpierse 6 år sedan
förälder
incheckning
f5608fdf5b
3 ändrade filer med 33 tillägg och 35 borttagningar
  1. 25
    31
      .idea/workspace.xml
  2. 5
    4
      arraz/src/main/java/Arraz.java
  3. 3
    0
      arraz/src/test/java/ArrazTest.java

+ 25
- 31
.idea/workspace.xml Visa fil

@@ -2,11 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="3455511b-a100-4bbd-b07c-68f009bc8dbc" name="Default" comment="">
5
-      <change afterPath="$PROJECT_DIR$/arraz/src/main/java/MinMax.java" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8 5
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
9
-      <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
10 6
     </list>
11 7
     <ignored path="$PROJECT_DIR$/arraz/target/" />
12 8
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -37,12 +33,12 @@
37 33
       </usages-collector>
38 34
       <usages-collector id="statistics.file.extensions.edit">
39 35
         <counts>
40
-          <entry key="java" value="3481" />
36
+          <entry key="java" value="3614" />
41 37
         </counts>
42 38
       </usages-collector>
43 39
       <usages-collector id="statistics.file.types.edit">
44 40
         <counts>
45
-          <entry key="JAVA" value="3481" />
41
+          <entry key="JAVA" value="3614" />
46 42
         </counts>
47 43
       </usages-collector>
48 44
     </session>
@@ -59,15 +55,14 @@
59 55
           <file pinned="false" current-in-tab="false">
60 56
             <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
61 57
               <provider selected="true" editor-type-id="text-editor">
62
-                <state relative-caret-position="369">
63
-                  <caret line="122" lean-forward="true" selection-start-line="122" selection-end-line="122" />
58
+                <state relative-caret-position="354">
59
+                  <caret line="119" column="22" selection-start-line="119" selection-start-column="22" selection-end-line="119" selection-end-column="22" />
64 60
                   <folding>
65 61
                     <element signature="imports" expanded="true" />
66 62
                     <element signature="e#414#415#0" expanded="true" />
67 63
                     <element signature="e#448#449#0" expanded="true" />
68 64
                     <element signature="e#535#536#0" expanded="true" />
69 65
                     <element signature="e#576#577#0" expanded="true" />
70
-                    <element signature="e#2864#2873#0" expanded="true" />
71 66
                     <element signature="e#2895#2904#0" expanded="true" />
72 67
                   </folding>
73 68
                 </state>
@@ -77,8 +72,8 @@
77 72
           <file pinned="false" current-in-tab="true">
78 73
             <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
79 74
               <provider selected="true" editor-type-id="text-editor">
80
-                <state relative-caret-position="372">
81
-                  <caret line="191" column="40" selection-start-line="191" selection-start-column="40" selection-end-line="191" selection-end-column="40" />
75
+                <state relative-caret-position="309">
76
+                  <caret line="191" column="43" lean-forward="true" selection-start-line="191" selection-start-column="43" selection-end-line="191" selection-end-column="43" />
82 77
                   <folding>
83 78
                     <element signature="imports" expanded="true" />
84 79
                     <element signature="e#1970#1971#0" expanded="true" />
@@ -169,8 +164,8 @@
169 164
         <option value="$PROJECT_DIR$/README.md" />
170 165
         <option value="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" />
171 166
         <option value="$PROJECT_DIR$/arraz/src/main/java/MinMax.java" />
172
-        <option value="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" />
173 167
         <option value="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" />
168
+        <option value="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" />
174 169
       </list>
175 170
     </option>
176 171
   </component>
@@ -240,7 +235,7 @@
240 235
     <property name="GO_FMT" value="false" />
241 236
     <property name="WebServerToolWindowFactoryState" value="false" />
242 237
     <property name="aspect.path.notification.shown" value="true" />
243
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544141205829" />
238
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544142316149" />
244 239
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
245 240
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
246 241
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
@@ -270,7 +265,7 @@
270 265
       </list>
271 266
     </option>
272 267
   </component>
273
-  <component name="RunManager" selected="JUnit.ArrazTest.test1RemoveDupes">
268
+  <component name="RunManager" selected="JUnit.ArrazTest.test2RemoveDupes">
274 269
     <configuration default="true" type="Applet" factoryName="Applet">
275 270
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
276 271
       <method v="2">
@@ -370,8 +365,8 @@
370 365
     </list>
371 366
     <recent_temporary>
372 367
       <list>
373
-        <item itemvalue="JUnit.ArrazTest.test1RemoveDupes" />
374 368
         <item itemvalue="JUnit.ArrazTest.test2RemoveDupes" />
369
+        <item itemvalue="JUnit.ArrazTest.test1RemoveDupes" />
375 370
         <item itemvalue="JUnit.ArrazTest.test2FindMinMax" />
376 371
         <item itemvalue="JUnit.ArrazTest.test1FindMinMax" />
377 372
         <item itemvalue="JUnit.ArrazTest.test2InsertIntoArrayAt" />
@@ -391,7 +386,7 @@
391 386
       <workItem from="1543955862749" duration="2347000" />
392 387
       <workItem from="1543958998826" duration="113000" />
393 388
       <workItem from="1544020724645" duration="762000" />
394
-      <workItem from="1544046527795" duration="13055000" />
389
+      <workItem from="1544046527795" duration="14260000" />
395 390
     </task>
396 391
     <task id="LOCAL-00001" summary="readme and docs">
397 392
       <created>1544021313039</created>
@@ -404,15 +399,6 @@
404 399
     <servers />
405 400
   </component>
406 401
   <component name="TestHistory">
407
-    <history-entry file="ArrazTest_test1RemoveElement - 2018.12.06 at 17h 55m 05s.xml">
408
-      <configuration name="ArrazTest.test1RemoveElement" configurationId="JUnit" />
409
-    </history-entry>
410
-    <history-entry file="ArrazTest_test1RemoveElement - 2018.12.06 at 17h 55m 18s.xml">
411
-      <configuration name="ArrazTest.test1RemoveElement" configurationId="JUnit" />
412
-    </history-entry>
413
-    <history-entry file="ArrazTest_test2RemoveElement - 2018.12.06 at 17h 55m 21s.xml">
414
-      <configuration name="ArrazTest.test2RemoveElement" configurationId="JUnit" />
415
-    </history-entry>
416 402
     <history-entry file="ArrazTest_test1InsertIntoArrayAt - 2018.12.06 at 18h 23m 24s.xml">
417 403
       <configuration name="ArrazTest.test1InsertIntoArrayAt" configurationId="JUnit" />
418 404
     </history-entry>
@@ -434,9 +420,18 @@
434 420
     <history-entry file="ArrazTest_test2FindMinMax - 2018.12.06 at 18h 43m 45s.xml">
435 421
       <configuration name="ArrazTest.test2FindMinMax" configurationId="JUnit" />
436 422
     </history-entry>
423
+    <history-entry file="ArrazTest_test1RemoveDupes - 2018.12.06 at 19h 04m 59s.xml">
424
+      <configuration name="ArrazTest.test1RemoveDupes" configurationId="JUnit" />
425
+    </history-entry>
426
+    <history-entry file="ArrazTest_test2RemoveDupes - 2018.12.06 at 19h 05m 07s.xml">
427
+      <configuration name="ArrazTest.test2RemoveDupes" configurationId="JUnit" />
428
+    </history-entry>
429
+    <history-entry file="ArrazTest_test1RemoveDupes - 2018.12.06 at 19h 06m 41s.xml">
430
+      <configuration name="ArrazTest.test1RemoveDupes" configurationId="JUnit" />
431
+    </history-entry>
437 432
   </component>
438 433
   <component name="TimeTrackingManager">
439
-    <option name="totallyTimeSpent" value="16277000" />
434
+    <option name="totallyTimeSpent" value="17482000" />
440 435
   </component>
441 436
   <component name="ToolWindowManager">
442 437
     <frame x="0" y="23" width="1440" height="805" extended-state="6" />
@@ -523,15 +518,14 @@
523 518
     </entry>
524 519
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
525 520
       <provider selected="true" editor-type-id="text-editor">
526
-        <state relative-caret-position="369">
527
-          <caret line="122" lean-forward="true" selection-start-line="122" selection-end-line="122" />
521
+        <state relative-caret-position="354">
522
+          <caret line="119" column="22" selection-start-line="119" selection-start-column="22" selection-end-line="119" selection-end-column="22" />
528 523
           <folding>
529 524
             <element signature="imports" expanded="true" />
530 525
             <element signature="e#414#415#0" expanded="true" />
531 526
             <element signature="e#448#449#0" expanded="true" />
532 527
             <element signature="e#535#536#0" expanded="true" />
533 528
             <element signature="e#576#577#0" expanded="true" />
534
-            <element signature="e#2864#2873#0" expanded="true" />
535 529
             <element signature="e#2895#2904#0" expanded="true" />
536 530
           </folding>
537 531
         </state>
@@ -539,8 +533,8 @@
539 533
     </entry>
540 534
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
541 535
       <provider selected="true" editor-type-id="text-editor">
542
-        <state relative-caret-position="372">
543
-          <caret line="191" column="40" selection-start-line="191" selection-start-column="40" selection-end-line="191" selection-end-column="40" />
536
+        <state relative-caret-position="309">
537
+          <caret line="191" column="43" lean-forward="true" selection-start-line="191" selection-start-column="43" selection-end-line="191" selection-end-column="43" />
544 538
           <folding>
545 539
             <element signature="imports" expanded="true" />
546 540
             <element signature="e#1970#1971#0" expanded="true" />

+ 5
- 4
arraz/src/main/java/Arraz.java Visa fil

@@ -109,15 +109,16 @@ public class Arraz {
109 109
     }
110 110
 
111 111
     public Integer[] removeDupes(Integer[] arr) {
112
-        ArrayList<Integer> result = new ArrayList<Integer>();
113 112
         Set<Integer> set = new HashSet<Integer>();
114 113
         for (Integer i : arr) {
115 114
             set.add(i);
116 115
         }
116
+        Integer[] result = new Integer[set.size()];
117
+        int counter = 0;
117 118
         for (Integer i: set) {
118
-            result.add(i);
119
+            result[counter]=i;
120
+            counter++;
119 121
         }
120
-        Integer[] foo = (Integer[]) result.toArray();
121
-        return foo;
122
+        return result;
122 123
     }
123 124
 }

+ 3
- 0
arraz/src/test/java/ArrazTest.java Visa fil

@@ -191,4 +191,7 @@ public class ArrazTest {
191 191
         arr = arraz.removeDupes(arr);
192 192
         Assert.assertEquals(arr.length, 5);
193 193
     }
194
+
195
+    @Test
196
+    
194 197
 }