2 次代码提交

作者 SHA1 备注 提交日期
  Seth 829f794f7d insersts 6 年前
  Seth 33d8195416 10s30 6 年前
共有 3 个文件被更改,包括 270 次插入81 次删除
  1. 111
    72
      .idea/workspace.xml
  2. 45
    4
      arraz/src/main/java/Arraz.java
  3. 114
    5
      arraz/src/test/java/ArrazTest.java

+ 111
- 72
.idea/workspace.xml 查看文件

@@ -2,7 +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/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6 5
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
7 6
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
8 7
     </list>
@@ -23,14 +22,14 @@
23 22
       </usages-collector>
24 23
       <usages-collector id="statistics.file.types.edit">
25 24
         <counts>
26
-          <entry key="JAVA" value="11042" />
25
+          <entry key="JAVA" value="14150" />
27 26
           <entry key="XML" value="3" />
28 27
         </counts>
29 28
       </usages-collector>
30 29
       <usages-collector id="statistics.file.types.open">
31 30
         <counts>
32 31
           <entry key="CLASS" value="1" />
33
-          <entry key="JAVA" value="5" />
32
+          <entry key="JAVA" value="6" />
34 33
           <entry key="XML" value="3" />
35 34
         </counts>
36 35
       </usages-collector>
@@ -39,22 +38,10 @@
39 38
   <component name="FileEditorManager">
40 39
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
41 40
       <file pinned="false" current-in-tab="false">
42
-        <entry file="file://$PROJECT_DIR$/README.md">
43
-          <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
44
-            <state split_layout="SPLIT">
45
-              <first_editor relative-caret-position="306">
46
-                <caret line="69" column="5" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
47
-              </first_editor>
48
-              <second_editor />
49
-            </state>
50
-          </provider>
51
-        </entry>
52
-      </file>
53
-      <file pinned="false" current-in-tab="true">
54 41
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
55 42
           <provider selected="true" editor-type-id="text-editor">
56
-            <state relative-caret-position="285">
57
-              <caret line="130" column="19" selection-start-line="130" selection-start-column="19" selection-end-line="130" selection-end-column="19" />
43
+            <state relative-caret-position="300">
44
+              <caret line="198" column="41" selection-start-line="198" selection-start-column="41" selection-end-line="198" selection-end-column="41" />
58 45
               <folding>
59 46
                 <element signature="e#3440#3441#0" expanded="true" />
60 47
                 <element signature="e#3482#3483#0" expanded="true" />
@@ -62,16 +49,24 @@
62 49
                 <element signature="e#3603#3604#0" expanded="true" />
63 50
                 <element signature="e#3677#3678#0" expanded="true" />
64 51
                 <element signature="e#3714#3715#0" expanded="true" />
52
+                <element signature="e#4954#4955#0" expanded="true" />
53
+                <element signature="e#4995#4996#0" expanded="true" />
54
+                <element signature="e#5042#5043#0" expanded="true" />
55
+                <element signature="e#5115#5116#0" expanded="true" />
56
+                <element signature="e#5173#5174#0" expanded="true" />
57
+                <element signature="e#5234#5235#0" expanded="true" />
58
+                <element signature="e#5305#5306#0" expanded="true" />
59
+                <element signature="e#5342#5343#0" expanded="true" />
65 60
               </folding>
66 61
             </state>
67 62
           </provider>
68 63
         </entry>
69 64
       </file>
70
-      <file pinned="false" current-in-tab="false">
65
+      <file pinned="false" current-in-tab="true">
71 66
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
72 67
           <provider selected="true" editor-type-id="text-editor">
73
-            <state relative-caret-position="253">
74
-              <caret line="256" column="72" selection-start-line="256" selection-start-column="72" selection-end-line="256" selection-end-column="72" />
68
+            <state relative-caret-position="300">
69
+              <caret line="462" column="5" lean-forward="true" selection-start-line="462" selection-start-column="5" selection-end-line="462" selection-end-column="5" />
75 70
               <folding>
76 71
                 <element signature="imports" expanded="true" />
77 72
               </folding>
@@ -80,6 +75,18 @@
80 75
         </entry>
81 76
       </file>
82 77
       <file pinned="false" current-in-tab="false">
78
+        <entry file="file://$PROJECT_DIR$/README.md">
79
+          <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
80
+            <state split_layout="SPLIT">
81
+              <first_editor relative-caret-position="306">
82
+                <caret line="69" column="5" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
83
+              </first_editor>
84
+              <second_editor />
85
+            </state>
86
+          </provider>
87
+        </entry>
88
+      </file>
89
+      <file pinned="false" current-in-tab="false">
83 90
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
84 91
           <provider selected="true" editor-type-id="text-editor">
85 92
             <state>
@@ -106,7 +113,10 @@
106 113
   </component>
107 114
   <component name="FindInProjectRecents">
108 115
     <findStrings>
116
+      <find>list</find>
117
+      <find>rev</find>
109 118
       <find>sort</find>
119
+      <find>rever</find>
110 120
     </findStrings>
111 121
   </component>
112 122
   <component name="Git.Settings">
@@ -220,7 +230,7 @@
220 230
     <property name="GO_FMT" value="false" />
221 231
     <property name="WebServerToolWindowFactoryState" value="false" />
222 232
     <property name="aspect.path.notification.shown" value="true" />
223
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544205690510" />
233
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544219473137" />
224 234
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
225 235
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
226 236
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
@@ -250,7 +260,7 @@
250 260
       </list>
251 261
     </option>
252 262
   </component>
253
-  <component name="RunManager" selected="JUnit.ArrazTest.testFind2ndLargestFromArray1">
263
+  <component name="RunManager" selected="JUnit.ArrazTest.testInsertEndCopy1">
254 264
     <configuration default="true" type="Applet" factoryName="Applet">
255 265
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
256 266
       <method v="2">
@@ -272,44 +282,44 @@
272 282
         <option name="Make" enabled="true" />
273 283
       </method>
274 284
     </configuration>
275
-    <configuration name="ArrazTest.testArrayHas65and771" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
285
+    <configuration name="ArrazTest.testInsertEndCopy1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
276 286
       <module name="arraz" />
277 287
       <option name="PACKAGE_NAME" value="" />
278 288
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
279
-      <option name="METHOD_NAME" value="testArrayHas65and771" />
289
+      <option name="METHOD_NAME" value="testInsertEndCopy1" />
280 290
       <option name="TEST_OBJECT" value="method" />
281 291
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
282 292
       <method v="2">
283 293
         <option name="Make" enabled="true" />
284 294
       </method>
285 295
     </configuration>
286
-    <configuration name="ArrazTest.testArrayHas65and772" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
296
+    <configuration name="ArrazTest.testInsertEndCopy2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
287 297
       <module name="arraz" />
288 298
       <option name="PACKAGE_NAME" value="" />
289 299
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
290
-      <option name="METHOD_NAME" value="testArrayHas65and772" />
300
+      <option name="METHOD_NAME" value="testInsertEndCopy2" />
291 301
       <option name="TEST_OBJECT" value="method" />
292 302
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
293 303
       <method v="2">
294 304
         <option name="Make" enabled="true" />
295 305
       </method>
296 306
     </configuration>
297
-    <configuration name="ArrazTest.testFind2ndLargestFromArray1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
307
+    <configuration name="ArrazTest.testInsertStartCopy1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
298 308
       <module name="arraz" />
299 309
       <option name="PACKAGE_NAME" value="" />
300 310
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
301
-      <option name="METHOD_NAME" value="testFind2ndLargestFromArray1" />
311
+      <option name="METHOD_NAME" value="testInsertStartCopy1" />
302 312
       <option name="TEST_OBJECT" value="method" />
303 313
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
304 314
       <method v="2">
305 315
         <option name="Make" enabled="true" />
306 316
       </method>
307 317
     </configuration>
308
-    <configuration name="ArrazTest.testFind2ndLargestFromArray2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
318
+    <configuration name="ArrazTest.testInsertStartCopy2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
309 319
       <module name="arraz" />
310 320
       <option name="PACKAGE_NAME" value="" />
311 321
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
312
-      <option name="METHOD_NAME" value="testFind2ndLargestFromArray2" />
322
+      <option name="METHOD_NAME" value="testInsertStartCopy2" />
313 323
       <option name="TEST_OBJECT" value="method" />
314 324
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
315 325
       <method v="2">
@@ -341,17 +351,17 @@
341 351
     </configuration>
342 352
     <list>
343 353
       <item itemvalue="JUnit.ArrazTest" />
344
-      <item itemvalue="JUnit.ArrazTest.testArrayHas65and771" />
345
-      <item itemvalue="JUnit.ArrazTest.testArrayHas65and772" />
346
-      <item itemvalue="JUnit.ArrazTest.testFind2ndLargestFromArray2" />
347
-      <item itemvalue="JUnit.ArrazTest.testFind2ndLargestFromArray1" />
354
+      <item itemvalue="JUnit.ArrazTest.testInsertStartCopy1" />
355
+      <item itemvalue="JUnit.ArrazTest.testInsertStartCopy2" />
356
+      <item itemvalue="JUnit.ArrazTest.testInsertEndCopy2" />
357
+      <item itemvalue="JUnit.ArrazTest.testInsertEndCopy1" />
348 358
     </list>
349 359
     <recent_temporary>
350 360
       <list>
351
-        <item itemvalue="JUnit.ArrazTest.testFind2ndLargestFromArray1" />
352
-        <item itemvalue="JUnit.ArrazTest.testFind2ndLargestFromArray2" />
353
-        <item itemvalue="JUnit.ArrazTest.testArrayHas65and772" />
354
-        <item itemvalue="JUnit.ArrazTest.testArrayHas65and771" />
361
+        <item itemvalue="JUnit.ArrazTest.testInsertEndCopy1" />
362
+        <item itemvalue="JUnit.ArrazTest.testInsertEndCopy2" />
363
+        <item itemvalue="JUnit.ArrazTest.testInsertStartCopy2" />
364
+        <item itemvalue="JUnit.ArrazTest.testInsertStartCopy1" />
355 365
         <item itemvalue="JUnit.ArrazTest" />
356 366
       </list>
357 367
     </recent_temporary>
@@ -369,7 +379,7 @@
369 379
       <workItem from="1543955862749" duration="2347000" />
370 380
       <workItem from="1543958998826" duration="113000" />
371 381
       <workItem from="1544020724645" duration="762000" />
372
-      <workItem from="1544046933389" duration="34996000" />
382
+      <workItem from="1544046933389" duration="44493000" />
373 383
     </task>
374 384
     <task id="LOCAL-00001" summary="readme and docs">
375 385
       <created>1544021313039</created>
@@ -382,39 +392,39 @@
382 392
     <servers />
383 393
   </component>
384 394
   <component name="TestHistory">
385
-    <history-entry file="ArrazTest_testArrayHas65and771 - 2018.12.07 at 10h 54m 19s.xml">
386
-      <configuration name="ArrazTest.testArrayHas65and771" configurationId="JUnit" />
395
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.07 at 16h 02m 54s.xml">
396
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
387 397
     </history-entry>
388
-    <history-entry file="ArrazTest_testArrayHas65and772 - 2018.12.07 at 10h 54m 23s.xml">
389
-      <configuration name="ArrazTest.testArrayHas65and772" configurationId="JUnit" />
398
+    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.07 at 16h 03m 30s.xml">
399
+      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
390 400
     </history-entry>
391
-    <history-entry file="ArrazTest_testAverageArrayWithoutMaxMin2 - 2018.12.07 at 12h 43m 07s.xml">
392
-      <configuration name="ArrazTest.testAverageArrayWithoutMaxMin2" configurationId="JUnit" />
401
+    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.07 at 16h 03m 55s.xml">
402
+      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
393 403
     </history-entry>
394
-    <history-entry file="ArrazTest_testAverageArrayWithoutMaxMin - 2018.12.07 at 12h 43m 51s.xml">
395
-      <configuration name="ArrazTest.testAverageArrayWithoutMaxMin" configurationId="JUnit" />
404
+    <history-entry file="ArrazTest - 2018.12.07 at 16h 05m 27s.xml">
405
+      <configuration name="ArrazTest" configurationId="JUnit" />
396 406
     </history-entry>
397
-    <history-entry file="ArrazTest_testAverageArrayWithoutMaxMin - 2018.12.07 at 12h 44m 05s.xml">
398
-      <configuration name="ArrazTest.testAverageArrayWithoutMaxMin" configurationId="JUnit" />
407
+    <history-entry file="ArrazTest_testInsertStartCopy1 - 2018.12.07 at 16h 31m 44s.xml">
408
+      <configuration name="ArrazTest.testInsertStartCopy1" configurationId="JUnit" />
399 409
     </history-entry>
400
-    <history-entry file="ArrazTest_test1SumValuesOfArray1 - 2018.12.07 at 12h 46m 13s.xml">
401
-      <configuration name="ArrazTest.test1SumValuesOfArray1" configurationId="JUnit" />
410
+    <history-entry file="ArrazTest_testInsertStartCopy2 - 2018.12.07 at 16h 31m 46s.xml">
411
+      <configuration name="ArrazTest.testInsertStartCopy2" configurationId="JUnit" />
402 412
     </history-entry>
403
-    <history-entry file="ArrazTest - 2018.12.07 at 12h 46m 18s.xml">
404
-      <configuration name="ArrazTest" configurationId="JUnit" />
413
+    <history-entry file="ArrazTest_testInsertEndCopy2 - 2018.12.07 at 16h 45m 50s.xml">
414
+      <configuration name="ArrazTest.testInsertEndCopy2" configurationId="JUnit" />
405 415
     </history-entry>
406
-    <history-entry file="ArrazTest_testArrayHas65and771 - 2018.12.07 at 12h 51m 30s.xml">
407
-      <configuration name="ArrazTest.testArrayHas65and771" configurationId="JUnit" />
416
+    <history-entry file="ArrazTest_testInsertEndCopy2 - 2018.12.07 at 16h 46m 24s.xml">
417
+      <configuration name="ArrazTest.testInsertEndCopy2" configurationId="JUnit" />
408 418
     </history-entry>
409
-    <history-entry file="ArrazTest_testArrayHas65and772 - 2018.12.07 at 12h 51m 33s.xml">
410
-      <configuration name="ArrazTest.testArrayHas65and772" configurationId="JUnit" />
419
+    <history-entry file="ArrazTest_testInsertEndCopy2 - 2018.12.07 at 16h 46m 57s.xml">
420
+      <configuration name="ArrazTest.testInsertEndCopy2" configurationId="JUnit" />
411 421
     </history-entry>
412
-    <history-entry file="ArrazTest_testArrayHas65and772 - 2018.12.07 at 12h 52m 03s.xml">
413
-      <configuration name="ArrazTest.testArrayHas65and772" configurationId="JUnit" />
422
+    <history-entry file="ArrazTest_testInsertEndCopy2 - 2018.12.07 at 16h 47m 14s.xml">
423
+      <configuration name="ArrazTest.testInsertEndCopy2" configurationId="JUnit" />
414 424
     </history-entry>
415 425
   </component>
416 426
   <component name="TimeTrackingManager">
417
-    <option name="totallyTimeSpent" value="38218000" />
427
+    <option name="totallyTimeSpent" value="47715000" />
418 428
   </component>
419 429
   <component name="ToolWindowManager">
420 430
     <frame x="1" y="23" width="1440" height="807" extended-state="0" />
@@ -490,6 +500,20 @@
490 500
     <MESSAGE value="readme and docs" />
491 501
     <option name="LAST_COMMIT_MESSAGE" value="readme and docs" />
492 502
   </component>
503
+  <component name="XDebuggerManager">
504
+    <breakpoint-manager>
505
+      <breakpoints>
506
+        <line-breakpoint enabled="true" type="java-method">
507
+          <url>file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java</url>
508
+          <line>206</line>
509
+          <properties class="ArrazTest" method="testInsertArrayAt2">
510
+            <option name="EMULATED" value="true" />
511
+          </properties>
512
+          <option name="timeStamp" value="26" />
513
+        </line-breakpoint>
514
+      </breakpoints>
515
+    </breakpoint-manager>
516
+  </component>
493 517
   <component name="editorHistoryManager">
494 518
     <entry file="file://$PROJECT_DIR$/arraz/pom.xml">
495 519
       <provider selected="true" editor-type-id="text-editor">
@@ -529,6 +553,13 @@
529 553
         </state>
530 554
       </provider>
531 555
     </entry>
556
+    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/src.zip!/java/util/ArrayList.java">
557
+      <provider selected="true" editor-type-id="text-editor">
558
+        <state relative-caret-position="-10766">
559
+          <caret line="106" column="13" selection-start-line="106" selection-start-column="13" selection-end-line="106" selection-end-column="13" />
560
+        </state>
561
+      </provider>
562
+    </entry>
532 563
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
533 564
       <provider selected="true" editor-type-id="text-editor">
534 565
         <state>
@@ -552,20 +583,10 @@
552 583
         </state>
553 584
       </provider>
554 585
     </entry>
555
-    <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
556
-      <provider selected="true" editor-type-id="text-editor">
557
-        <state relative-caret-position="253">
558
-          <caret line="256" column="72" selection-start-line="256" selection-start-column="72" selection-end-line="256" selection-end-column="72" />
559
-          <folding>
560
-            <element signature="imports" expanded="true" />
561
-          </folding>
562
-        </state>
563
-      </provider>
564
-    </entry>
565 586
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
566 587
       <provider selected="true" editor-type-id="text-editor">
567
-        <state relative-caret-position="285">
568
-          <caret line="130" column="19" selection-start-line="130" selection-start-column="19" selection-end-line="130" selection-end-column="19" />
588
+        <state relative-caret-position="300">
589
+          <caret line="198" column="41" selection-start-line="198" selection-start-column="41" selection-end-line="198" selection-end-column="41" />
569 590
           <folding>
570 591
             <element signature="e#3440#3441#0" expanded="true" />
571 592
             <element signature="e#3482#3483#0" expanded="true" />
@@ -573,6 +594,24 @@
573 594
             <element signature="e#3603#3604#0" expanded="true" />
574 595
             <element signature="e#3677#3678#0" expanded="true" />
575 596
             <element signature="e#3714#3715#0" expanded="true" />
597
+            <element signature="e#4954#4955#0" expanded="true" />
598
+            <element signature="e#4995#4996#0" expanded="true" />
599
+            <element signature="e#5042#5043#0" expanded="true" />
600
+            <element signature="e#5115#5116#0" expanded="true" />
601
+            <element signature="e#5173#5174#0" expanded="true" />
602
+            <element signature="e#5234#5235#0" expanded="true" />
603
+            <element signature="e#5305#5306#0" expanded="true" />
604
+            <element signature="e#5342#5343#0" expanded="true" />
605
+          </folding>
606
+        </state>
607
+      </provider>
608
+    </entry>
609
+    <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
610
+      <provider selected="true" editor-type-id="text-editor">
611
+        <state relative-caret-position="300">
612
+          <caret line="462" column="5" lean-forward="true" selection-start-line="462" selection-start-column="5" selection-end-line="462" selection-end-column="5" />
613
+          <folding>
614
+            <element signature="imports" expanded="true" />
576 615
           </folding>
577 616
         </state>
578 617
       </provider>

+ 45
- 4
arraz/src/main/java/Arraz.java 查看文件

@@ -104,11 +104,12 @@ public class Arraz {
104 104
     public int[] insertArrayAt(int[] array, int index, int value){
105 105
         int[] newArray = new int[array.length + 1];
106 106
         int counter = 0;
107
-        for (int i = 0; i < array.length-1; i++) {
108
-            if (i == index){
109
-                newArray[index] = value;
107
+        for (int i = 0; i < array.length; i++) {
108
+            if (counter == index){
109
+                newArray[counter] = value;
110 110
                 counter++;
111
-            }else {
111
+                i--;
112
+            }else{
112 113
                 newArray[counter] = array[i];
113 114
                 counter++;
114 115
             }
@@ -157,4 +158,44 @@ public class Arraz {
157 158
                 return true;
158 159
             }else{return false;}
159 160
     }
161
+
162
+    public boolean theTotalOfTenIs30(Integer[] array){
163
+        int sum10 = 0;
164
+        for (Integer each:array){
165
+            if(each == 10){
166
+                sum10 += each;
167
+                if(sum10 == 30){
168
+                    return true;
169
+                }
170
+            }
171
+        }
172
+        return false;
173
+    }
174
+
175
+    public Integer[] min2Array(Integer[] array){
176
+        Set<Integer> minSet = new TreeSet<>(Arrays.asList(array));
177
+        return Arrays.copyOfRange(minSet.toArray(new Integer[0]), 0, 2);
178
+    }
179
+
180
+    public int[] reverseCopy(int[] array){
181
+       return reverseArray(array);
182
+    }
183
+
184
+    public int[] removeLastItemCopy(int[] array){
185
+        return removeElementFromArray(array, array[array.length-1]);
186
+    }
187
+
188
+    public int[] removeFirstItemCopy(int[] array){
189
+        return removeElementFromArray(array, array[0]);
190
+    }
191
+
192
+    public int[] insertStartCopy(int[] array, int value){
193
+        return insertArrayAt(array, 0, value);
194
+    }
195
+
196
+    public Integer[] insertEndCopy(Integer[] array, int value){
197
+        List<Integer> list = new ArrayList<>(Arrays.asList(array));
198
+        list.add(value);
199
+        return list.toArray(new Integer[0]);
200
+    }
160 201
 }

+ 114
- 5
arraz/src/test/java/ArrazTest.java 查看文件

@@ -3,7 +3,6 @@
3 3
 import org.junit.Assert;
4 4
 import org.junit.Before;
5 5
 import org.junit.Test;
6
-
7 6
 import java.util.ArrayList;
8 7
 import java.util.Arrays;
9 8
 import java.util.List;
@@ -197,16 +196,18 @@ public class ArrazTest {
197 196
 
198 197
     @Test
199 198
     public void testInsertArrayAt1(){
200
-        int[] expected = new int[]{5, 10, 17, 3, 29, 100};
201
-        int[] actual = testArraz.insertArrayAt(arr1, 2, 17);
199
+        int[] expected = new int[]{5, 10, 3, 17, 29, 100};
200
+        int[] actual = testArraz.insertArrayAt(arr1, 3, 17);
201
+        System.out.println(Arrays.toString(actual));
202 202
 
203 203
         Assert.assertArrayEquals(expected, actual);
204 204
     }
205 205
 
206 206
     @Test
207 207
     public void testInsertArrayAt2(){
208
-        int[] expected =  new int[]{2, 7, 432, 89, 6};
209
-        int[] actual = testArraz.insertArrayAt(arr2, 4, 6);
208
+        int[] expected =  new int[]{2, 6, 7, 432, 89};
209
+        int[] actual = testArraz.insertArrayAt(arr2, 1, 6);
210
+        System.out.println(Arrays.toString(actual));
210 211
 
211 212
         Assert.assertArrayEquals(expected, actual);
212 213
     }
@@ -352,4 +353,112 @@ public class ArrazTest {
352 353
         Assert.assertFalse(testArraz.arrayHas65and77(array));
353 354
     }
354 355
 
356
+    @Test
357
+    public void testTheTotalOfTenIs301() {
358
+        Integer[] array = new Integer[]{10, 4, 3, 10, 56, 10};
359
+        Assert.assertTrue(testArraz.theTotalOfTenIs30(array));
360
+    }
361
+
362
+    @Test
363
+    public void testTheTotalOfTenIs302(){
364
+        Integer[] array = new Integer[]{10, 98, 2, 34,10};
365
+        Assert.assertFalse(testArraz.theTotalOfTenIs30(array));
366
+    }
367
+
368
+    @Test
369
+    public void testMin2Array1(){
370
+        Integer[] expected = new Integer[]{3, 5};
371
+        Integer[] actual = testArraz.min2Array(new Integer[]{100, 54, 10, 78, 10, 5, 3});
372
+
373
+        Assert.assertArrayEquals(expected, actual);
374
+    }
375
+
376
+    @Test
377
+    public void testMin2Array(){
378
+        Integer[] expected = new Integer[]{1, 10};
379
+        Integer[] actual = testArraz.min2Array(new Integer[]{1,1,1,1,10});
380
+
381
+        Assert.assertArrayEquals(expected, actual);
382
+    }
383
+
384
+    @Test
385
+    public void testReverseCopy1(){
386
+        int[] expected = new int[]{100, 29, 3, 10, 5};
387
+        int[] actual = testArraz.reverseCopy(arr1);
388
+
389
+        Assert.assertArrayEquals(expected,actual);
390
+    }
391
+
392
+    @Test
393
+    public void testReverseCopy2(){
394
+        int[] expected = new int[]{89, 432, 7, 2};
395
+        int[] actual = testArraz.reverseCopy(arr2);
396
+
397
+        Assert.assertArrayEquals(expected, actual);
398
+    }
399
+
400
+    @Test
401
+    public void testRemoveLastItemCopy1(){
402
+        int[] expected = new int[]{5, 10, 3, 29};
403
+        int[] actual = testArraz.removeLastItemCopy(arr1);
404
+
405
+        Assert.assertArrayEquals(expected, actual);
406
+    }
407
+
408
+    @Test
409
+    public void testRemoveLastItemCopy2(){
410
+        int[] expected =  new int[]{2, 7, 432};
411
+        int[] actual = testArraz.removeLastItemCopy(arr2);
412
+
413
+        Assert.assertArrayEquals(expected, actual);
414
+    }
415
+
416
+    @Test
417
+    public void testRemoveFirstItemCopy1(){
418
+        int[] expected = new int[]{7, 432, 89};
419
+        int[] actual = testArraz.removeFirstItemCopy(arr2);
420
+
421
+        Assert.assertArrayEquals(expected, actual);
422
+    }
423
+
424
+    @Test
425
+    public void testRemoveFirstItemCopy2(){
426
+        int[] expected = new int[]{10, 3, 29, 100};
427
+        int[] actual = testArraz.removeFirstItemCopy(arr1);
428
+
429
+        Assert.assertArrayEquals(expected, actual);
430
+    }
431
+
432
+    @Test
433
+    public void testInsertStartCopy1(){
434
+        int[] expected = new int[]{4, 5, 10, 3, 29, 100};
435
+        int[] actual = testArraz.insertStartCopy(arr1, 4);
436
+
437
+        Assert.assertArrayEquals(expected, actual);
438
+    }
439
+
440
+    @Test
441
+    public void testInsertStartCopy2(){
442
+        int[] expected = new int[]{56, 2, 7, 432, 89};
443
+        int[] actual = testArraz.insertStartCopy(arr2, 56);
444
+
445
+        Assert.assertArrayEquals(expected, actual);
446
+    }
447
+
448
+    @Test
449
+    public void testInsertEndCopy1(){
450
+        Integer[] expected = new Integer[]{2, 7, 432, 89, 9};
451
+        Integer[] actual = testArraz.insertEndCopy(new Integer[]{2, 7, 432, 89}, 9);
452
+
453
+        Assert.assertArrayEquals(expected, actual);
454
+    }
455
+
456
+    @Test
457
+    public void testInsertEndCopy2(){
458
+        Integer[] expected = new Integer[]{5, 10, 3, 29, 100, 90};
459
+        Integer[] actual = testArraz.insertEndCopy(new Integer[]{5, 10, 3, 29, 100}, 90);
460
+        System.out.println(Arrays.toString(actual));
461
+
462
+        Assert.assertArrayEquals(expected, actual);
463
+    }
355 464
 }