Seth 6 gadus atpakaļ
vecāks
revīzija
648e017ddd

+ 74
- 55
.idea/workspace.xml Parādīt failu

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 beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
5
       <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" />
6
       <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" />
7
     </list>
8
     </list>
22
       </usages-collector>
23
       </usages-collector>
23
       <usages-collector id="statistics.file.types.edit">
24
       <usages-collector id="statistics.file.types.edit">
24
         <counts>
25
         <counts>
25
-          <entry key="JAVA" value="7260" />
26
+          <entry key="JAVA" value="7562" />
26
           <entry key="XML" value="3" />
27
           <entry key="XML" value="3" />
27
         </counts>
28
         </counts>
28
       </usages-collector>
29
       </usages-collector>
29
       <usages-collector id="statistics.file.types.open">
30
       <usages-collector id="statistics.file.types.open">
30
         <counts>
31
         <counts>
31
-          <entry key="JAVA" value="3" />
32
+          <entry key="CLASS" value="1" />
33
+          <entry key="JAVA" value="4" />
32
           <entry key="XML" value="3" />
34
           <entry key="XML" value="3" />
33
         </counts>
35
         </counts>
34
       </usages-collector>
36
       </usages-collector>
36
   </component>
38
   </component>
37
   <component name="FileEditorManager">
39
   <component name="FileEditorManager">
38
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
40
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
39
-      <file pinned="false" current-in-tab="false">
41
+      <file pinned="false" current-in-tab="true">
40
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
42
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
41
           <provider selected="true" editor-type-id="text-editor">
43
           <provider selected="true" editor-type-id="text-editor">
42
-            <state relative-caret-position="334">
43
-              <caret line="231" column="49" lean-forward="true" selection-start-line="231" selection-start-column="49" selection-end-line="231" selection-end-column="49" />
44
+            <state relative-caret-position="167">
45
+              <caret line="224" column="52" selection-start-line="224" selection-start-column="52" selection-end-line="224" selection-end-column="52" />
44
               <folding>
46
               <folding>
45
                 <element signature="imports" expanded="true" />
47
                 <element signature="imports" expanded="true" />
46
                 <element signature="e#4388#4389#0" expanded="true" />
48
                 <element signature="e#4388#4389#0" expanded="true" />
50
           </provider>
52
           </provider>
51
         </entry>
53
         </entry>
52
       </file>
54
       </file>
53
-      <file pinned="false" current-in-tab="true">
55
+      <file pinned="false" current-in-tab="false">
54
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
56
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
55
           <provider selected="true" editor-type-id="text-editor">
57
           <provider selected="true" editor-type-id="text-editor">
56
-            <state relative-caret-position="359">
57
-              <caret line="130" column="26" selection-start-line="130" selection-start-column="26" selection-end-line="130" selection-end-column="26" />
58
-              <folding>
59
-                <element signature="imports" expanded="true" />
60
-              </folding>
58
+            <state relative-caret-position="313">
59
+              <caret line="127" lean-forward="true" selection-start-line="127" selection-end-line="127" />
60
+            </state>
61
+          </provider>
62
+        </entry>
63
+      </file>
64
+      <file pinned="false" current-in-tab="false">
65
+        <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/src.zip!/java/util/Set.java">
66
+          <provider selected="true" editor-type-id="text-editor">
67
+            <state relative-caret-position="386">
68
+              <caret line="189" column="17" selection-start-line="189" selection-start-column="17" selection-end-line="189" selection-end-column="17" />
61
             </state>
69
             </state>
62
           </provider>
70
           </provider>
63
         </entry>
71
         </entry>
207
     <property name="GO_FMT" value="false" />
215
     <property name="GO_FMT" value="false" />
208
     <property name="WebServerToolWindowFactoryState" value="false" />
216
     <property name="WebServerToolWindowFactoryState" value="false" />
209
     <property name="aspect.path.notification.shown" value="true" />
217
     <property name="aspect.path.notification.shown" value="true" />
210
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544139093969" />
218
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544188738035" />
211
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
219
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
212
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
220
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
213
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
221
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
358
       <workItem from="1543955862749" duration="2347000" />
366
       <workItem from="1543955862749" duration="2347000" />
359
       <workItem from="1543958998826" duration="113000" />
367
       <workItem from="1543958998826" duration="113000" />
360
       <workItem from="1544020724645" duration="762000" />
368
       <workItem from="1544020724645" duration="762000" />
361
-      <workItem from="1544046933389" duration="20210000" />
369
+      <workItem from="1544046933389" duration="22466000" />
362
     </task>
370
     </task>
363
     <task id="LOCAL-00001" summary="readme and docs">
371
     <task id="LOCAL-00001" summary="readme and docs">
364
       <created>1544021313039</created>
372
       <created>1544021313039</created>
371
     <servers />
379
     <servers />
372
   </component>
380
   </component>
373
   <component name="TestHistory">
381
   <component name="TestHistory">
374
-    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 08m 11s.xml">
375
-      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
382
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 05s.xml">
383
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
376
     </history-entry>
384
     </history-entry>
377
-    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 08m 38s.xml">
378
-      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
385
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 50s.xml">
386
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
379
     </history-entry>
387
     </history-entry>
380
-    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 08m 41s.xml">
381
-      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
388
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 59s.xml">
389
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
382
     </history-entry>
390
     </history-entry>
383
-    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 11m 02s.xml">
384
-      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
391
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 34m 13s.xml">
392
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
385
     </history-entry>
393
     </history-entry>
386
-    <history-entry file="ArrazTest_testInsertArrayAt1 - 2018.12.06 at 16h 11m 14s.xml">
387
-      <configuration name="ArrazTest.testInsertArrayAt1" configurationId="JUnit" />
394
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 35m 05s.xml">
395
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
388
     </history-entry>
396
     </history-entry>
389
-    <history-entry file="ArrazTest_testInsertArrayAt2 - 2018.12.06 at 16h 11m 17s.xml">
390
-      <configuration name="ArrazTest.testInsertArrayAt2" configurationId="JUnit" />
397
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.07 at 07h 58m 33s.xml">
398
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
391
     </history-entry>
399
     </history-entry>
392
-    <history-entry file="ArrazTest_testCopyArrayByIterator1 - 2018.12.06 at 16h 59m 54s.xml">
393
-      <configuration name="ArrazTest.testCopyArrayByIterator1" configurationId="JUnit" />
400
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.07 at 08h 12m 08s.xml">
401
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
394
     </history-entry>
402
     </history-entry>
395
-    <history-entry file="ArrazTest_testCopyArrayByIterator2 - 2018.12.06 at 16h 59m 57s.xml">
396
-      <configuration name="ArrazTest.testCopyArrayByIterator2" configurationId="JUnit" />
403
+    <history-entry file="ArrazTest_testRemoveDupesFromArray1 - 2018.12.07 at 08h 12m 26s.xml">
404
+      <configuration name="ArrazTest.testRemoveDupesFromArray1" configurationId="JUnit" />
397
     </history-entry>
405
     </history-entry>
398
-    <history-entry file="ArrazTest_testFindMaxMinOfArray1 - 2018.12.06 at 18h 11m 28s.xml">
399
-      <configuration name="ArrazTest.testFindMaxMinOfArray1" configurationId="JUnit" />
406
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.07 at 08h 15m 25s.xml">
407
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
400
     </history-entry>
408
     </history-entry>
401
-    <history-entry file="ArrazTest_testFindMaxMinOfArray2 - 2018.12.06 at 18h 11m 30s.xml">
402
-      <configuration name="ArrazTest.testFindMaxMinOfArray2" configurationId="JUnit" />
409
+    <history-entry file="ArrazTest_testRemoveDupesFromArray1 - 2018.12.07 at 08h 15m 32s.xml">
410
+      <configuration name="ArrazTest.testRemoveDupesFromArray1" configurationId="JUnit" />
403
     </history-entry>
411
     </history-entry>
404
   </component>
412
   </component>
405
   <component name="TimeTrackingManager">
413
   <component name="TimeTrackingManager">
406
-    <option name="totallyTimeSpent" value="23432000" />
414
+    <option name="totallyTimeSpent" value="25688000" />
407
   </component>
415
   </component>
408
   <component name="ToolWindowManager">
416
   <component name="ToolWindowManager">
409
     <frame x="1" y="23" width="1440" height="807" extended-state="0" />
417
     <frame x="1" y="23" width="1440" height="807" extended-state="0" />
457
         </state>
465
         </state>
458
       </provider>
466
       </provider>
459
     </entry>
467
     </entry>
460
-    <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
461
-      <provider selected="true" editor-type-id="text-editor">
462
-        <state>
463
-          <caret column="22" selection-start-column="22" selection-end-column="22" />
464
-          <folding>
465
-            <element signature="e#189#190#0" expanded="true" />
466
-            <element signature="e#215#216#0" expanded="true" />
467
-            <element signature="e#308#309#0" expanded="true" />
468
-            <element signature="e#335#336#0" expanded="true" />
469
-          </folding>
470
-        </state>
471
-      </provider>
472
-    </entry>
473
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/MaxMin.java">
468
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/MaxMin.java">
474
       <provider selected="true" editor-type-id="text-editor">
469
       <provider selected="true" editor-type-id="text-editor">
475
         <state>
470
         <state>
487
         </state>
482
         </state>
488
       </provider>
483
       </provider>
489
     </entry>
484
     </entry>
490
-    <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
485
+    <entry file="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/org/junit/internal/runners/model/ReflectiveCallable.class">
491
       <provider selected="true" editor-type-id="text-editor">
486
       <provider selected="true" editor-type-id="text-editor">
492
-        <state relative-caret-position="334">
493
-          <caret line="231" column="49" lean-forward="true" selection-start-line="231" selection-start-column="49" selection-end-line="231" selection-end-column="49" />
487
+        <state relative-caret-position="210">
488
+          <caret line="17" selection-start-line="17" selection-end-line="17" />
489
+        </state>
490
+      </provider>
491
+    </entry>
492
+    <entry file="file://$PROJECT_DIR$/arraz/src/main/java/OddEven.java">
493
+      <provider selected="true" editor-type-id="text-editor">
494
+        <state>
495
+          <caret column="22" selection-start-column="22" selection-end-column="22" />
494
           <folding>
496
           <folding>
495
-            <element signature="imports" expanded="true" />
496
-            <element signature="e#4388#4389#0" expanded="true" />
497
-            <element signature="e#4411#4412#0" expanded="true" />
497
+            <element signature="e#189#190#0" expanded="true" />
498
+            <element signature="e#215#216#0" expanded="true" />
499
+            <element signature="e#308#309#0" expanded="true" />
500
+            <element signature="e#335#336#0" expanded="true" />
498
           </folding>
501
           </folding>
499
         </state>
502
         </state>
500
       </provider>
503
       </provider>
501
     </entry>
504
     </entry>
505
+    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/src.zip!/java/util/Set.java">
506
+      <provider selected="true" editor-type-id="text-editor">
507
+        <state relative-caret-position="386">
508
+          <caret line="189" column="17" selection-start-line="189" selection-start-column="17" selection-end-line="189" selection-end-column="17" />
509
+        </state>
510
+      </provider>
511
+    </entry>
502
     <entry file="file://$PROJECT_DIR$/README.md">
512
     <entry file="file://$PROJECT_DIR$/README.md">
503
       <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
513
       <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
504
         <state split_layout="SPLIT">
514
         <state split_layout="SPLIT">
511
     </entry>
521
     </entry>
512
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
522
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
513
       <provider selected="true" editor-type-id="text-editor">
523
       <provider selected="true" editor-type-id="text-editor">
514
-        <state relative-caret-position="359">
515
-          <caret line="130" column="26" selection-start-line="130" selection-start-column="26" selection-end-line="130" selection-end-column="26" />
524
+        <state relative-caret-position="313">
525
+          <caret line="127" lean-forward="true" selection-start-line="127" selection-end-line="127" />
526
+        </state>
527
+      </provider>
528
+    </entry>
529
+    <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
530
+      <provider selected="true" editor-type-id="text-editor">
531
+        <state relative-caret-position="167">
532
+          <caret line="224" column="52" selection-start-line="224" selection-start-column="52" selection-end-line="224" selection-end-column="52" />
516
           <folding>
533
           <folding>
517
             <element signature="imports" expanded="true" />
534
             <element signature="imports" expanded="true" />
535
+            <element signature="e#4388#4389#0" expanded="true" />
536
+            <element signature="e#4411#4412#0" expanded="true" />
518
           </folding>
537
           </folding>
519
         </state>
538
         </state>
520
       </provider>
539
       </provider>

+ 3
- 8
arraz/src/main/java/Arraz.java Parādīt failu

1
-import java.util.Arrays;
2
-import java.util.HashSet;
3
-import java.util.Iterator;
4
-import java.util.Set;
1
+import java.util.*;
5
 
2
 
6
 public class Arraz {
3
 public class Arraz {
7
 
4
 
125
     }
122
     }
126
 
123
 
127
     public Integer[] removeDupesFromArray(Integer[] array){
124
     public Integer[] removeDupesFromArray(Integer[] array){
128
-        Set<Integer> integerSet = new HashSet<>();
129
-        integerSet.addAll(Arrays.asList(array));
130
-        Integer[] integers = new Integer[integerSet.size()];
131
-        return integerSet.toArray(integers);
125
+        Set<Integer> integerSet = new LinkedHashSet<>(Arrays.asList(array));
126
+        return integerSet.toArray(new Integer[0]);
132
     }
127
     }
133
 
128
 
134
 }
129
 }

+ 16
- 1
arraz/src/test/java/ArrazTest.java Parādīt failu

222
         Integer[] array1 = new Integer[]{1,3 ,4, 3, 7, 7, 10};
222
         Integer[] array1 = new Integer[]{1,3 ,4, 3, 7, 7, 10};
223
         Integer[] expected = new Integer[]{1, 3, 4, 7, 10};
223
         Integer[] expected = new Integer[]{1, 3, 4, 7, 10};
224
         Integer[] actual = testArraz.removeDupesFromArray(array1);
224
         Integer[] actual = testArraz.removeDupesFromArray(array1);
225
+        System.out.println(Arrays.toString(actual));
225
 
226
 
226
         Assert.assertArrayEquals(expected, actual);
227
         Assert.assertArrayEquals(expected, actual);
227
     }
228
     }
228
 
229
 
229
     @Test
230
     @Test
230
     public void testRemoveDupesFromArray2(){
231
     public void testRemoveDupesFromArray2(){
231
-        Integer[] array1 = new Integer[]{5, 1, 1, 1, 1 ,1};
232
+        Integer[] array1 = new Integer[]{5, 1, 5, 5, 5 ,5};
232
         Integer[] expected = new Integer[]{5, 1};
233
         Integer[] expected = new Integer[]{5, 1};
233
         Integer[] actual = testArraz.removeDupesFromArray(array1);
234
         Integer[] actual = testArraz.removeDupesFromArray(array1);
235
+        System.out.println(Arrays.toString(actual));
234
 
236
 
235
         Assert.assertArrayEquals(expected, actual);
237
         Assert.assertArrayEquals(expected, actual);
236
     }
238
     }
239
+
240
+//    @Test
241
+//    public void testFind2ndLargestFromArray1(){
242
+//        double expected = 38.4;
243
+//        double actual = testArraz.find2ndLargestFromArray();
244
+//
245
+//        Assert.assertEquals(expected, actual, .01);
246
+//    }
247
+//
248
+//    @Test
249
+//    public void testFind2ndLargestFromArray2(){
250
+//
251
+//    }
237
 }
252
 }