Seth 6 years ago
parent
commit
05b7a2f609
3 changed files with 77 additions and 46 deletions
  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 View File

2
 <project version="4">
2
 <project version="4">
3
   <component name="ChangeListManager">
3
   <component name="ChangeListManager">
4
     <list default="true" id="3455511b-a100-4bbd-b07c-68f009bc8dbc" name="Default" comment="">
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
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
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
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
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
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
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
     </list>
8
     </list>
29
       </usages-collector>
23
       </usages-collector>
30
       <usages-collector id="statistics.file.types.edit">
24
       <usages-collector id="statistics.file.types.edit">
31
         <counts>
25
         <counts>
32
-          <entry key="JAVA" value="3519" />
26
+          <entry key="JAVA" value="4128" />
33
           <entry key="XML" value="3" />
27
           <entry key="XML" value="3" />
34
         </counts>
28
         </counts>
35
       </usages-collector>
29
       </usages-collector>
46
       <file pinned="false" current-in-tab="false">
40
       <file pinned="false" current-in-tab="false">
47
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
41
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
48
           <provider selected="true" editor-type-id="text-editor">
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
               <folding>
45
               <folding>
46
+                <element signature="imports" expanded="true" />
52
                 <element signature="e#399#400#0" expanded="true" />
47
                 <element signature="e#399#400#0" expanded="true" />
53
                 <element signature="e#451#452#0" expanded="true" />
48
                 <element signature="e#451#452#0" expanded="true" />
54
                 <element signature="e#515#516#0" expanded="true" />
49
                 <element signature="e#515#516#0" expanded="true" />
61
       <file pinned="false" current-in-tab="true">
56
       <file pinned="false" current-in-tab="true">
62
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
57
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
63
           <provider selected="true" editor-type-id="text-editor">
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
               <folding>
61
               <folding>
67
                 <element signature="imports" expanded="true" />
62
                 <element signature="imports" expanded="true" />
68
               </folding>
63
               </folding>
85
       <file pinned="false" current-in-tab="false">
80
       <file pinned="false" current-in-tab="false">
86
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
81
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
87
           <provider selected="true" editor-type-id="text-editor">
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
               <folding>
85
               <folding>
86
+                <element signature="e#189#190#0" expanded="true" />
91
                 <element signature="e#215#216#0" expanded="true" />
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
                 <element signature="e#308#309#0" expanded="true" />
88
                 <element signature="e#308#309#0" expanded="true" />
95
                 <element signature="e#335#336#0" expanded="true" />
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
               </folding>
90
               </folding>
99
             </state>
91
             </state>
100
           </provider>
92
           </provider>
216
     <property name="GO_FMT" value="false" />
208
     <property name="GO_FMT" value="false" />
217
     <property name="WebServerToolWindowFactoryState" value="false" />
209
     <property name="WebServerToolWindowFactoryState" value="false" />
218
     <property name="aspect.path.notification.shown" value="true" />
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
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
212
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
221
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
213
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
222
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
214
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
246
       </list>
238
       </list>
247
     </option>
239
     </option>
248
   </component>
240
   </component>
249
-  <component name="RunManager" selected="JUnit.ArrazTest">
241
+  <component name="RunManager" selected="JUnit.ArrazTest.testCopyArrayByIterator2">
250
     <configuration default="true" type="Applet" factoryName="Applet">
242
     <configuration default="true" type="Applet" factoryName="Applet">
251
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
243
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
252
       <method v="2">
244
       <method v="2">
268
         <option name="Make" enabled="true" />
260
         <option name="Make" enabled="true" />
269
       </method>
261
       </method>
270
     </configuration>
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
       <module name="arraz" />
264
       <module name="arraz" />
273
       <option name="PACKAGE_NAME" value="" />
265
       <option name="PACKAGE_NAME" value="" />
274
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
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
       <option name="TEST_OBJECT" value="method" />
279
       <option name="TEST_OBJECT" value="method" />
277
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
280
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
278
       <method v="2">
281
       <method v="2">
327
     <list>
330
     <list>
328
       <item itemvalue="JUnit.ArrazTest" />
331
       <item itemvalue="JUnit.ArrazTest" />
329
       <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
332
       <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
330
-      <item itemvalue="JUnit.ArrazTest.testOddEvens1" />
331
       <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
333
       <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
334
+      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator1" />
335
+      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
332
     </list>
336
     </list>
333
     <recent_temporary>
337
     <recent_temporary>
334
       <list>
338
       <list>
339
+        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
340
+        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator1" />
335
         <item itemvalue="JUnit.ArrazTest" />
341
         <item itemvalue="JUnit.ArrazTest" />
336
-        <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
337
-        <item itemvalue="JUnit.ArrazTest.testOddEvens1" />
338
         <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
342
         <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
343
+        <item itemvalue="JUnit.ArrazTest.testOddEvens2" />
339
       </list>
344
       </list>
340
     </recent_temporary>
345
     </recent_temporary>
341
   </component>
346
   </component>
352
       <workItem from="1543955862749" duration="2347000" />
357
       <workItem from="1543955862749" duration="2347000" />
353
       <workItem from="1543958998826" duration="113000" />
358
       <workItem from="1543958998826" duration="113000" />
354
       <workItem from="1544020724645" duration="762000" />
359
       <workItem from="1544020724645" duration="762000" />
355
-      <workItem from="1544046933389" duration="7694000" />
360
+      <workItem from="1544046933389" duration="9103000" />
356
     </task>
361
     </task>
357
     <task id="LOCAL-00001" summary="readme and docs">
362
     <task id="LOCAL-00001" summary="readme and docs">
358
       <created>1544021313039</created>
363
       <created>1544021313039</created>
365
     <servers />
370
     <servers />
366
   </component>
371
   </component>
367
   <component name="TestHistory">
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
     <history-entry file="ArrazTest_testReverseArray1 - 2018.12.05 at 19h 49m 37s.xml">
373
     <history-entry file="ArrazTest_testReverseArray1 - 2018.12.05 at 19h 49m 37s.xml">
378
       <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
374
       <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
379
     </history-entry>
375
     </history-entry>
395
     <history-entry file="ArrazTest - 2018.12.05 at 20h 14m 26s.xml">
391
     <history-entry file="ArrazTest - 2018.12.05 at 20h 14m 26s.xml">
396
       <configuration name="ArrazTest" configurationId="JUnit" />
392
       <configuration name="ArrazTest" configurationId="JUnit" />
397
     </history-entry>
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
   </component>
403
   </component>
399
   <component name="TimeTrackingManager">
404
   <component name="TimeTrackingManager">
400
-    <option name="totallyTimeSpent" value="10916000" />
405
+    <option name="totallyTimeSpent" value="12325000" />
401
   </component>
406
   </component>
402
   <component name="ToolWindowManager">
407
   <component name="ToolWindowManager">
403
     <frame x="0" y="23" width="1440" height="807" extended-state="6" />
408
     <frame x="0" y="23" width="1440" height="807" extended-state="6" />
453
     </entry>
458
     </entry>
454
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
459
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
455
       <provider selected="true" editor-type-id="text-editor">
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
           <folding>
463
           <folding>
464
+            <element signature="e#189#190#0" expanded="true" />
459
             <element signature="e#215#216#0" expanded="true" />
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
             <element signature="e#308#309#0" expanded="true" />
466
             <element signature="e#308#309#0" expanded="true" />
463
             <element signature="e#335#336#0" expanded="true" />
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
           </folding>
468
           </folding>
467
         </state>
469
         </state>
468
       </provider>
470
       </provider>
479
     </entry>
481
     </entry>
480
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
482
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
481
       <provider selected="true" editor-type-id="text-editor">
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
           <folding>
486
           <folding>
487
+            <element signature="imports" expanded="true" />
485
             <element signature="e#399#400#0" expanded="true" />
488
             <element signature="e#399#400#0" expanded="true" />
486
             <element signature="e#451#452#0" expanded="true" />
489
             <element signature="e#451#452#0" expanded="true" />
487
             <element signature="e#515#516#0" expanded="true" />
490
             <element signature="e#515#516#0" expanded="true" />
492
     </entry>
495
     </entry>
493
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
496
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
494
       <provider selected="true" editor-type-id="text-editor">
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
           <folding>
500
           <folding>
498
             <element signature="imports" expanded="true" />
501
             <element signature="imports" expanded="true" />
499
           </folding>
502
           </folding>

+ 14
- 1
arraz/src/main/java/Arraz.java View File

1
+import java.util.Arrays;
2
+import java.util.Iterator;
3
+
1
 public class Arraz {
4
 public class Arraz {
2
 
5
 
3
 
6
 
66
         return -1;
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 View File

146
         Assert.assertEquals(expected,actual);
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
 }