Seth před 6 roky
rodič
revize
eaade35bd8

+ 79
- 68
.idea/workspace.xml Zobrazit soubor

@@ -2,10 +2,6 @@
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 beforePath="$PROJECT_DIR$/.idea/ArraysGoneWild.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/ArraysGoneWild.iml" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9 5
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
10 6
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
11 7
     </list>
@@ -26,14 +22,14 @@
26 22
       </usages-collector>
27 23
       <usages-collector id="statistics.file.types.edit">
28 24
         <counts>
29
-          <entry key="JAVA" value="5174" />
25
+          <entry key="JAVA" value="5964" />
30 26
           <entry key="XML" value="3" />
31 27
         </counts>
32 28
       </usages-collector>
33 29
       <usages-collector id="statistics.file.types.open">
34 30
         <counts>
35 31
           <entry key="JAVA" value="2" />
36
-          <entry key="XML" value="1" />
32
+          <entry key="XML" value="2" />
37 33
         </counts>
38 34
       </usages-collector>
39 35
     </session>
@@ -43,8 +39,8 @@
43 39
       <file pinned="false" current-in-tab="false">
44 40
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
45 41
           <provider selected="true" editor-type-id="text-editor">
46
-            <state relative-caret-position="-902">
47
-              <caret line="109" column="50" selection-start-line="109" selection-start-column="50" selection-end-line="109" selection-end-column="50" />
42
+            <state relative-caret-position="358">
43
+              <caret line="209" selection-start-line="209" selection-end-line="209" />
48 44
               <folding>
49 45
                 <element signature="imports" expanded="true" />
50 46
                 <element signature="e#4388#4389#0" expanded="true" />
@@ -54,11 +50,11 @@
54 50
           </provider>
55 51
         </entry>
56 52
       </file>
57
-      <file pinned="false" current-in-tab="true">
53
+      <file pinned="false" current-in-tab="false">
58 54
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
59 55
           <provider selected="true" editor-type-id="text-editor">
60 56
             <state relative-caret-position="343">
61
-              <caret line="103" lean-forward="true" selection-start-line="103" selection-end-line="103" />
57
+              <caret line="113" column="13" selection-start-line="113" selection-start-column="13" selection-end-line="113" selection-end-column="13" />
62 58
               <folding>
63 59
                 <element signature="imports" expanded="true" />
64 60
               </folding>
@@ -66,12 +62,12 @@
66 62
           </provider>
67 63
         </entry>
68 64
       </file>
69
-      <file pinned="false" current-in-tab="false">
65
+      <file pinned="false" current-in-tab="true">
70 66
         <entry file="file://$PROJECT_DIR$/README.md">
71 67
           <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
72 68
             <state split_layout="SPLIT">
73
-              <first_editor relative-caret-position="381">
74
-                <caret line="74" column="117" selection-start-line="74" selection-start-column="113" selection-end-line="74" selection-end-column="117" />
69
+              <first_editor relative-caret-position="306">
70
+                <caret line="69" column="5" lean-forward="true" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
75 71
               </first_editor>
76 72
               <second_editor />
77 73
             </state>
@@ -124,8 +120,8 @@
124 120
         <option value="$PROJECT_DIR$/README.md" />
125 121
         <option value="$PROJECT_DIR$/arraz/pom.xml" />
126 122
         <option value="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" />
127
-        <option value="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" />
128 123
         <option value="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" />
124
+        <option value="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" />
129 125
       </list>
130 126
     </option>
131 127
   </component>
@@ -209,7 +205,7 @@
209 205
     <property name="GO_FMT" value="false" />
210 206
     <property name="WebServerToolWindowFactoryState" value="false" />
211 207
     <property name="aspect.path.notification.shown" value="true" />
212
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544126310211" />
208
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544130899575" />
213 209
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
214 210
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
215 211
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
@@ -239,7 +235,7 @@
239 235
       </list>
240 236
     </option>
241 237
   </component>
242
-  <component name="RunManager" selected="JUnit.ArrazTest.testRemoveElementFromArray1">
238
+  <component name="RunManager" selected="JUnit.ArrazTest.testInsertArrayAt2">
243 239
     <configuration default="true" type="Applet" factoryName="Applet">
244 240
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
245 241
       <method v="2">
@@ -261,22 +257,22 @@
261 257
         <option name="Make" enabled="true" />
262 258
       </method>
263 259
     </configuration>
264
-    <configuration name="ArrazTest.testCopyArrayByIterator1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
260
+    <configuration name="ArrazTest.testInsertArrayAt1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
265 261
       <module name="arraz" />
266 262
       <option name="PACKAGE_NAME" value="" />
267 263
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
268
-      <option name="METHOD_NAME" value="testCopyArrayByIterator1" />
264
+      <option name="METHOD_NAME" value="testInsertArrayAt1" />
269 265
       <option name="TEST_OBJECT" value="method" />
270 266
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
271 267
       <method v="2">
272 268
         <option name="Make" enabled="true" />
273 269
       </method>
274 270
     </configuration>
275
-    <configuration name="ArrazTest.testCopyArrayByIterator2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
271
+    <configuration name="ArrazTest.testInsertArrayAt2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
276 272
       <module name="arraz" />
277 273
       <option name="PACKAGE_NAME" value="" />
278 274
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
279
-      <option name="METHOD_NAME" value="testCopyArrayByIterator2" />
275
+      <option name="METHOD_NAME" value="testInsertArrayAt2" />
280 276
       <option name="TEST_OBJECT" value="method" />
281 277
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
282 278
       <method v="2">
@@ -331,17 +327,17 @@
331 327
     <list>
332 328
       <item itemvalue="JUnit.ArrazTest" />
333 329
       <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
334
-      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator1" />
335
-      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
336 330
       <item itemvalue="JUnit.ArrazTest.testRemoveElementFromArray1" />
331
+      <item itemvalue="JUnit.ArrazTest.testInsertArrayAt1" />
332
+      <item itemvalue="JUnit.ArrazTest.testInsertArrayAt2" />
337 333
     </list>
338 334
     <recent_temporary>
339 335
       <list>
336
+        <item itemvalue="JUnit.ArrazTest.testInsertArrayAt2" />
337
+        <item itemvalue="JUnit.ArrazTest.testInsertArrayAt1" />
340 338
         <item itemvalue="JUnit.ArrazTest.testRemoveElementFromArray1" />
341 339
         <item itemvalue="JUnit.ArrazTest" />
342 340
         <item itemvalue="JUnit.ArrazTest.testReverseArray1" />
343
-        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
344
-        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator1" />
345 341
       </list>
346 342
     </recent_temporary>
347 343
   </component>
@@ -358,7 +354,7 @@
358 354
       <workItem from="1543955862749" duration="2347000" />
359 355
       <workItem from="1543958998826" duration="113000" />
360 356
       <workItem from="1544020724645" duration="762000" />
361
-      <workItem from="1544046933389" duration="12355000" />
357
+      <workItem from="1544046933389" duration="14993000" />
362 358
     </task>
363 359
     <task id="LOCAL-00001" summary="readme and docs">
364 360
       <created>1544021313039</created>
@@ -371,42 +367,43 @@
371 367
     <servers />
372 368
   </component>
373 369
   <component name="TestHistory">
374
-    <history-entry file="ArrazTest - 2018.12.05 at 20h 14m 10s.xml">
375
-      <configuration name="ArrazTest" configurationId="JUnit" />
370
+    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 15h 31m 04s.xml">
371
+      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
376 372
     </history-entry>
377
-    <history-entry file="ArrazTest - 2018.12.05 at 20h 14m 26s.xml">
378
-      <configuration name="ArrazTest" configurationId="JUnit" />
373
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 15h 31m 08s.xml">
374
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
379 375
     </history-entry>
380
-    <history-entry file="ArrazTest - 2018.12.05 at 20h 21m 34s.xml">
381
-      <configuration name="ArrazTest" configurationId="JUnit" />
376
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 03m 55s.xml">
377
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
382 378
     </history-entry>
383
-    <history-entry file="ArrazTest_testReverseArray1 - 2018.12.05 at 20h 36m 49s.xml">
384
-      <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
379
+    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 08m 09s.xml">
380
+      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
385 381
     </history-entry>
386
-    <history-entry file="ArrazTest - 2018.12.06 at 08h 17m 38s.xml">
387
-      <configuration name="ArrazTest" configurationId="JUnit" />
382
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 08m 11s.xml">
383
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
388 384
     </history-entry>
389
-    <history-entry file="ArrazTest_testCopyArrayByIterator1 - 2018.12.06 at 08h 34m 19s.xml">
390
-      <configuration name="ArrazTest.testCopyArrayByIterator1" configurationId="JUnit" />
385
+    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 08m 38s.xml">
386
+      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
391 387
     </history-entry>
392
-    <history-entry file="ArrazTest_testCopyArrayByIterator2 - 2018.12.06 at 08h 34m 23s.xml">
393
-      <configuration name="ArrazTest.testCopyArrayByIterator2" configurationId="JUnit" />
388
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 08m 41s.xml">
389
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
394 390
     </history-entry>
395
-    <history-entry file="ArrazTest - 2018.12.06 at 13h 17m 56s.xml">
396
-      <configuration name="ArrazTest" configurationId="JUnit" />
391
+    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 11m 02s.xml">
392
+      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
397 393
     </history-entry>
398
-    <history-entry file="ArrazTest_testReverseArray1 - 2018.12.06 at 14h 52m 25s.xml">
399
-      <configuration name="ArrazTest.testReverseArray1" configurationId="JUnit" />
394
+    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 11m 14s.xml">
395
+      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
400 396
     </history-entry>
401
-    <history-entry file="ArrazTest - 2018.12.06 at 14h 53m 48s.xml">
402
-      <configuration name="ArrazTest" configurationId="JUnit" />
397
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 11m 17s.xml">
398
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
403 399
     </history-entry>
404 400
   </component>
405 401
   <component name="TimeTrackingManager">
406
-    <option name="totallyTimeSpent" value="15577000" />
402
+    <option name="totallyTimeSpent" value="18215000" />
407 403
   </component>
408 404
   <component name="ToolWindowManager">
409 405
     <frame x="0" y="23" width="1440" height="807" extended-state="6" />
406
+    <editor active="true" />
410 407
     <layout>
411 408
       <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26108727" />
412 409
       <window_info id="Structure" order="1" weight="0.25" />
@@ -448,14 +445,21 @@
448 445
     <MESSAGE value="readme and docs" />
449 446
     <option name="LAST_COMMIT_MESSAGE" value="readme and docs" />
450 447
   </component>
448
+  <component name="XDebuggerManager">
449
+    <breakpoint-manager>
450
+      <breakpoints>
451
+        <line-breakpoint enabled="true" type="java-method">
452
+          <url>file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java</url>
453
+          <line>103</line>
454
+          <properties class="Arraz" method="insertArrayAt">
455
+            <option name="EMULATED" value="true" />
456
+          </properties>
457
+          <option name="timeStamp" value="4" />
458
+        </line-breakpoint>
459
+      </breakpoints>
460
+    </breakpoint-manager>
461
+  </component>
451 462
   <component name="editorHistoryManager">
452
-    <entry file="file://$PROJECT_DIR$/arraz/pom.xml">
453
-      <provider selected="true" editor-type-id="text-editor">
454
-        <state relative-caret-position="240">
455
-          <caret line="16" selection-start-line="16" selection-end-line="16" />
456
-        </state>
457
-      </provider>
458
-    </entry>
459 463
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
460 464
       <provider selected="true" editor-type-id="text-editor">
461 465
         <state>
@@ -469,38 +473,45 @@
469 473
         </state>
470 474
       </provider>
471 475
     </entry>
472
-    <entry file="file://$PROJECT_DIR$/README.md">
473
-      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
474
-        <state split_layout="SPLIT">
475
-          <first_editor relative-caret-position="381">
476
-            <caret line="74" column="117" selection-start-line="74" selection-start-column="113" selection-end-line="74" selection-end-column="117" />
477
-          </first_editor>
478
-          <second_editor />
476
+    <entry file="file://$PROJECT_DIR$/arraz/pom.xml">
477
+      <provider selected="true" editor-type-id="text-editor">
478
+        <state relative-caret-position="240">
479
+          <caret line="16" selection-start-line="16" selection-end-line="16" />
479 480
         </state>
480 481
       </provider>
481 482
     </entry>
482
-    <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
483
+    <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
483 484
       <provider selected="true" editor-type-id="text-editor">
484
-        <state relative-caret-position="-902">
485
-          <caret line="109" column="50" selection-start-line="109" selection-start-column="50" selection-end-line="109" selection-end-column="50" />
485
+        <state relative-caret-position="343">
486
+          <caret line="113" column="13" selection-start-line="113" selection-start-column="13" selection-end-line="113" selection-end-column="13" />
486 487
           <folding>
487 488
             <element signature="imports" expanded="true" />
488
-            <element signature="e#4388#4389#0" expanded="true" />
489
-            <element signature="e#4411#4412#0" expanded="true" />
490 489
           </folding>
491 490
         </state>
492 491
       </provider>
493 492
     </entry>
494
-    <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
493
+    <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
495 494
       <provider selected="true" editor-type-id="text-editor">
496
-        <state relative-caret-position="343">
497
-          <caret line="103" lean-forward="true" selection-start-line="103" selection-end-line="103" />
495
+        <state relative-caret-position="358">
496
+          <caret line="209" selection-start-line="209" selection-end-line="209" />
498 497
           <folding>
499 498
             <element signature="imports" expanded="true" />
499
+            <element signature="e#4388#4389#0" expanded="true" />
500
+            <element signature="e#4411#4412#0" expanded="true" />
500 501
           </folding>
501 502
         </state>
502 503
       </provider>
503 504
     </entry>
505
+    <entry file="file://$PROJECT_DIR$/README.md">
506
+      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
507
+        <state split_layout="SPLIT">
508
+          <first_editor relative-caret-position="306">
509
+            <caret line="69" column="5" lean-forward="true" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
510
+          </first_editor>
511
+          <second_editor />
512
+        </state>
513
+      </provider>
514
+    </entry>
504 515
   </component>
505 516
   <component name="masterDetails">
506 517
     <states>

+ 15
- 0
arraz/src/main/java/Arraz.java Zobrazit soubor

@@ -100,4 +100,19 @@ public class Arraz {
100 100
         }
101 101
         return newArray;
102 102
     }
103
+
104
+    public int[] insertArrayAt(int[] array, int index, int value){
105
+        int[] newArray = new int[array.length + 1];
106
+        int counter = 0;
107
+        for (int i = 0; i < array.length-1; i++) {
108
+            if (i == index){
109
+                newArray[index] = value;
110
+                counter++;
111
+            }else {
112
+                newArray[counter] = array[i];
113
+                counter++;
114
+            }
115
+        }
116
+        return newArray;
117
+        }
103 118
 }

+ 18
- 0
arraz/src/test/java/ArrazTest.java Zobrazit soubor

@@ -190,4 +190,22 @@ public class ArrazTest {
190 190
 
191 191
         Assert.assertArrayEquals(expected, actual);
192 192
     }
193
+
194
+    @Test
195
+    public void testInsertArrayAt1(){
196
+        int[] expected = new int[]{5, 10, 17, 3, 29, 100};
197
+        int[] actual = testArraz.insertArrayAt(arr1, 2, 17);
198
+
199
+        Assert.assertArrayEquals(expected, actual);
200
+    }
201
+
202
+    @Test
203
+    public void testInsertArrayAt2(){
204
+        int[] expected =  new int[]{2, 7, 432, 89, 6};
205
+        int[] actual = testArraz.insertArrayAt(arr2, 4, 6);
206
+
207
+        Assert.assertArrayEquals(expected, actual);
208
+    }
209
+
210
+
193 211
 }