Seth 6 jaren geleden
bovenliggende
commit
05b7a2f609
3 gewijzigde bestanden met toevoegingen van 77 en 46 verwijderingen
  1. 48
    45
      .idea/workspace.xml
  2. 14
    1
      arraz/src/main/java/Arraz.java
  3. 15
    0
      arraz/src/test/java/ArrazTest.java

+ 48
- 45
.idea/workspace.xml Bestand weergeven

@@ -2,13 +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$/.idea/libraries/Maven__junit_junit_4_12.xml" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml" afterDir="false" />
7
-      <change afterPath="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__junit_junit_4_0.xml" beforeDir="false" />
9 5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/arraz/arraz.iml" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/arraz.iml" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/arraz/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/pom.xml" afterDir="false" />
12 6
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
13 7
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
14 8
     </list>
@@ -29,7 +23,7 @@
29 23
       </usages-collector>
30 24
       <usages-collector id="statistics.file.types.edit">
31 25
         <counts>
32
-          <entry key="JAVA" value="3519" />
26
+          <entry key="JAVA" value="4128" />
33 27
           <entry key="XML" value="3" />
34 28
         </counts>
35 29
       </usages-collector>
@@ -46,9 +40,10 @@
46 40
       <file pinned="false" current-in-tab="false">
47 41
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
48 42
           <provider selected="true" editor-type-id="text-editor">
49
-            <state relative-caret-position="368">
50
-              <caret line="65" column="18" selection-start-line="65" selection-start-column="18" selection-end-line="65" selection-end-column="18" />
43
+            <state relative-caret-position="285">
44
+              <caret line="79" column="24" selection-start-line="79" selection-start-column="24" selection-end-line="79" selection-end-column="24" />
51 45
               <folding>
46
+                <element signature="imports" expanded="true" />
52 47
                 <element signature="e#399#400#0" expanded="true" />
53 48
                 <element signature="e#451#452#0" expanded="true" />
54 49
                 <element signature="e#515#516#0" expanded="true" />
@@ -61,8 +56,8 @@
61 56
       <file pinned="false" current-in-tab="true">
62 57
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
63 58
           <provider selected="true" editor-type-id="text-editor">
64
-            <state relative-caret-position="2190">
65
-              <caret line="146" column="5" lean-forward="true" selection-start-line="146" selection-start-column="5" selection-end-line="146" selection-end-column="5" />
59
+            <state relative-caret-position="313">
60
+              <caret line="161" column="49" selection-start-line="161" selection-start-column="49" selection-end-line="161" selection-end-column="49" />
66 61
               <folding>
67 62
                 <element signature="imports" expanded="true" />
68 63
               </folding>
@@ -85,16 +80,13 @@
85 80
       <file pinned="false" current-in-tab="false">
86 81
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
87 82
           <provider selected="true" editor-type-id="text-editor">
88
-            <state relative-caret-position="150">
89
-              <caret line="10" column="25" selection-start-line="10" selection-start-column="25" selection-end-line="10" selection-end-column="25" />
83
+            <state>
84
+              <caret column="22" lean-forward="true" selection-start-column="22" selection-end-column="22" />
90 85
               <folding>
86
+                <element signature="e#189#190#0" expanded="true" />
91 87
                 <element signature="e#215#216#0" expanded="true" />
92
-                <element signature="e#250#251#0" expanded="true" />
93
-                <element signature="e#280#281#0" expanded="true" />
94 88
                 <element signature="e#308#309#0" expanded="true" />
95 89
                 <element signature="e#335#336#0" expanded="true" />
96
-                <element signature="e#372#373#0" expanded="true" />
97
-                <element signature="e#404#405#0" expanded="true" />
98 90
               </folding>
99 91
             </state>
100 92
           </provider>
@@ -216,7 +208,7 @@
216 208
     <property name="GO_FMT" value="false" />
217 209
     <property name="WebServerToolWindowFactoryState" value="false" />
218 210
     <property name="aspect.path.notification.shown" value="true" />
219
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544059292553" />
211
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544103261992" />
220 212
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
221 213
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
222 214
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
@@ -246,7 +238,7 @@
246 238
       </list>
247 239
     </option>
248 240
   </component>
249
-  <component name="RunManager" selected="JUnit.ArrazTest">
241
+  <component name="RunManager" selected="JUnit.ArrazTest.testCopyArrayByIterator2">
250 242
     <configuration default="true" type="Applet" factoryName="Applet">
251 243
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
252 244
       <method v="2">
@@ -268,11 +260,22 @@
268 260
         <option name="Make" enabled="true" />
269 261
       </method>
270 262
     </configuration>
271
-    <configuration name="ArrazTest.testOddEvens1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
263
+    <configuration name="ArrazTest.testCopyArrayByIterator1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
272 264
       <module name="arraz" />
273 265
       <option name="PACKAGE_NAME" value="" />
274 266
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
275
-      <option name="METHOD_NAME" value="testOddEvens1" />
267
+      <option name="METHOD_NAME" value="testCopyArrayByIterator1" />
268
+      <option name="TEST_OBJECT" value="method" />
269
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
270
+      <method v="2">
271
+        <option name="Make" enabled="true" />
272
+      </method>
273
+    </configuration>
274
+    <configuration name="ArrazTest.testCopyArrayByIterator2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
275
+      <module name="arraz" />
276
+      <option name="PACKAGE_NAME" value="" />
277
+      <option name="MAIN_CLASS_NAME" value="ArrazTest" />
278
+      <option name="METHOD_NAME" value="testCopyArrayByIterator2" />
276 279
       <option name="TEST_OBJECT" value="method" />
277 280
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
278 281
       <method v="2">
@@ -327,15 +330,17 @@
327 330
     <list>
328 331
       <item itemvalue="JUnit.ArrazTest" />
329 332
       <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
330
-      <item itemvalue="JUnit.ArrazTest.testOddEvens1" />
331 333
       <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
334
+      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator1" />
335
+      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
332 336
     </list>
333 337
     <recent_temporary>
334 338
       <list>
339
+        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
340
+        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator1" />
335 341
         <item itemvalue="JUnit.ArrazTest" />
336
-        <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
337
-        <item itemvalue="JUnit.ArrazTest.testOddEvens1" />
338 342
         <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
343
+        <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
339 344
       </list>
340 345
     </recent_temporary>
341 346
   </component>
@@ -352,7 +357,7 @@
352 357
       <workItem from="1543955862749" duration="2347000" />
353 358
       <workItem from="1543958998826" duration="113000" />
354 359
       <workItem from="1544020724645" duration="762000" />
355
-      <workItem from="1544046933389" duration="7694000" />
360
+      <workItem from="1544046933389" duration="9103000" />
356 361
     </task>
357 362
     <task id="LOCAL-00001" summary="readme and docs">
358 363
       <created>1544021313039</created>
@@ -365,15 +370,6 @@
365 370
     <servers />
366 371
   </component>
367 372
   <component name="TestHistory">
368
-    <history-entry file="ArrazTest - 2018.12.05 at 19h 33m 31s.xml">
369
-      <configuration name="ArrazTest" configurationId="JUnit" />
370
-    </history-entry>
371
-    <history-entry file="ArrazTest - 2018.12.05 at 19h 48m 37s.xml">
372
-      <configuration name="ArrazTest" configurationId="JUnit" />
373
-    </history-entry>
374
-    <history-entry file="ArrazTest_testReverseArray1 - 2018.12.05 at 19h 49m 22s.xml">
375
-      <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
376
-    </history-entry>
377 373
     <history-entry file="ArrazTest_testReverseArray1 - 2018.12.05 at 19h 49m 37s.xml">
378 374
       <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
379 375
     </history-entry>
@@ -395,9 +391,18 @@
395 391
     <history-entry file="ArrazTest - 2018.12.05 at 20h 14m 26s.xml">
396 392
       <configuration name="ArrazTest" configurationId="JUnit" />
397 393
     </history-entry>
394
+    <history-entry file="ArrazTest - 2018.12.05 at 20h 21m 34s.xml">
395
+      <configuration name="ArrazTest" configurationId="JUnit" />
396
+    </history-entry>
397
+    <history-entry file="ArrazTest_testReverseArray1 - 2018.12.05 at 20h 36m 49s.xml">
398
+      <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
399
+    </history-entry>
400
+    <history-entry file="ArrazTest - 2018.12.06 at 08h 17m 38s.xml">
401
+      <configuration name="ArrazTest" configurationId="JUnit" />
402
+    </history-entry>
398 403
   </component>
399 404
   <component name="TimeTrackingManager">
400
-    <option name="totallyTimeSpent" value="10916000" />
405
+    <option name="totallyTimeSpent" value="12325000" />
401 406
   </component>
402 407
   <component name="ToolWindowManager">
403 408
     <frame x="0" y="23" width="1440" height="807" extended-state="6" />
@@ -453,16 +458,13 @@
453 458
     </entry>
454 459
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
455 460
       <provider selected="true" editor-type-id="text-editor">
456
-        <state relative-caret-position="150">
457
-          <caret line="10" column="25" selection-start-line="10" selection-start-column="25" selection-end-line="10" selection-end-column="25" />
461
+        <state>
462
+          <caret column="22" lean-forward="true" selection-start-column="22" selection-end-column="22" />
458 463
           <folding>
464
+            <element signature="e#189#190#0" expanded="true" />
459 465
             <element signature="e#215#216#0" expanded="true" />
460
-            <element signature="e#250#251#0" expanded="true" />
461
-            <element signature="e#280#281#0" expanded="true" />
462 466
             <element signature="e#308#309#0" expanded="true" />
463 467
             <element signature="e#335#336#0" expanded="true" />
464
-            <element signature="e#372#373#0" expanded="true" />
465
-            <element signature="e#404#405#0" expanded="true" />
466 468
           </folding>
467 469
         </state>
468 470
       </provider>
@@ -479,9 +481,10 @@
479 481
     </entry>
480 482
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
481 483
       <provider selected="true" editor-type-id="text-editor">
482
-        <state relative-caret-position="368">
483
-          <caret line="65" column="18" selection-start-line="65" selection-start-column="18" selection-end-line="65" selection-end-column="18" />
484
+        <state relative-caret-position="285">
485
+          <caret line="79" column="24" selection-start-line="79" selection-start-column="24" selection-end-line="79" selection-end-column="24" />
484 486
           <folding>
487
+            <element signature="imports" expanded="true" />
485 488
             <element signature="e#399#400#0" expanded="true" />
486 489
             <element signature="e#451#452#0" expanded="true" />
487 490
             <element signature="e#515#516#0" expanded="true" />
@@ -492,8 +495,8 @@
492 495
     </entry>
493 496
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
494 497
       <provider selected="true" editor-type-id="text-editor">
495
-        <state relative-caret-position="2190">
496
-          <caret line="146" column="5" lean-forward="true" selection-start-line="146" selection-start-column="5" selection-end-line="146" selection-end-column="5" />
498
+        <state relative-caret-position="313">
499
+          <caret line="161" column="49" selection-start-line="161" selection-start-column="49" selection-end-line="161" selection-end-column="49" />
497 500
           <folding>
498 501
             <element signature="imports" expanded="true" />
499 502
           </folding>

+ 14
- 1
arraz/src/main/java/Arraz.java Bestand weergeven

@@ -1,3 +1,6 @@
1
+import java.util.Arrays;
2
+import java.util.Iterator;
3
+
1 4
 public class Arraz {
2 5
 
3 6
 
@@ -66,5 +69,15 @@ public class Arraz {
66 69
         return -1;
67 70
     }
68 71
 
72
+    public Integer[] copyArrayByIterator(Integer[] array){
73
+        Integer[] newArray = new Integer[array.length];
74
+        int index = 0;
75
+        Iterator<Integer> iterator = Arrays.asList(array).iterator();
76
+        while(iterator.hasNext()){
77
+            newArray[index] = iterator.next();
78
+            index++;
79
+        }
80
+        return newArray;
81
+        }
69 82
 
70
-}
83
+    }

+ 15
- 0
arraz/src/test/java/ArrazTest.java Bestand weergeven

@@ -146,4 +146,19 @@ public class ArrazTest {
146 146
         Assert.assertEquals(expected,actual);
147 147
     }
148 148
 
149
+    @Test
150
+    public void testCopyArrayByIterator1(){
151
+        Integer[] expected = new Integer[]{1,2,3,4,5};
152
+        Integer[] actual = testArraz.copyArrayByIterator(expected);
153
+
154
+        Assert.assertArrayEquals(expected, actual);
155
+    }
156
+
157
+    @Test
158
+    public void testCopyArrayByIterator2(){
159
+        Integer[] expected = new Integer[]{10, 3, 5, 43};
160
+        Integer[] actual = testArraz.copyArrayByIterator(expected);
161
+
162
+        Assert.assertArrayEquals(expected, actual);
163
+    }
149 164
 }