Browse Source

completed dupes

mpierse 6 years ago
parent
commit
f5608fdf5b
3 changed files with 33 additions and 35 deletions
  1. 25
    31
      .idea/workspace.xml
  2. 5
    4
      arraz/src/main/java/Arraz.java
  3. 3
    0
      arraz/src/test/java/ArrazTest.java

+ 25
- 31
.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$/arraz/src/main/java/MinMax.java" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" 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" />
9
-      <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
10
     </list>
6
     </list>
11
     <ignored path="$PROJECT_DIR$/arraz/target/" />
7
     <ignored path="$PROJECT_DIR$/arraz/target/" />
12
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
8
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
37
       </usages-collector>
33
       </usages-collector>
38
       <usages-collector id="statistics.file.extensions.edit">
34
       <usages-collector id="statistics.file.extensions.edit">
39
         <counts>
35
         <counts>
40
-          <entry key="java" value="3481" />
36
+          <entry key="java" value="3614" />
41
         </counts>
37
         </counts>
42
       </usages-collector>
38
       </usages-collector>
43
       <usages-collector id="statistics.file.types.edit">
39
       <usages-collector id="statistics.file.types.edit">
44
         <counts>
40
         <counts>
45
-          <entry key="JAVA" value="3481" />
41
+          <entry key="JAVA" value="3614" />
46
         </counts>
42
         </counts>
47
       </usages-collector>
43
       </usages-collector>
48
     </session>
44
     </session>
59
           <file pinned="false" current-in-tab="false">
55
           <file pinned="false" current-in-tab="false">
60
             <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
56
             <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
61
               <provider selected="true" editor-type-id="text-editor">
57
               <provider selected="true" editor-type-id="text-editor">
62
-                <state relative-caret-position="369">
63
-                  <caret line="122" lean-forward="true" selection-start-line="122" selection-end-line="122" />
58
+                <state relative-caret-position="354">
59
+                  <caret line="119" column="22" selection-start-line="119" selection-start-column="22" selection-end-line="119" selection-end-column="22" />
64
                   <folding>
60
                   <folding>
65
                     <element signature="imports" expanded="true" />
61
                     <element signature="imports" expanded="true" />
66
                     <element signature="e#414#415#0" expanded="true" />
62
                     <element signature="e#414#415#0" expanded="true" />
67
                     <element signature="e#448#449#0" expanded="true" />
63
                     <element signature="e#448#449#0" expanded="true" />
68
                     <element signature="e#535#536#0" expanded="true" />
64
                     <element signature="e#535#536#0" expanded="true" />
69
                     <element signature="e#576#577#0" expanded="true" />
65
                     <element signature="e#576#577#0" expanded="true" />
70
-                    <element signature="e#2864#2873#0" expanded="true" />
71
                     <element signature="e#2895#2904#0" expanded="true" />
66
                     <element signature="e#2895#2904#0" expanded="true" />
72
                   </folding>
67
                   </folding>
73
                 </state>
68
                 </state>
77
           <file pinned="false" current-in-tab="true">
72
           <file pinned="false" current-in-tab="true">
78
             <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
73
             <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
79
               <provider selected="true" editor-type-id="text-editor">
74
               <provider selected="true" editor-type-id="text-editor">
80
-                <state relative-caret-position="372">
81
-                  <caret line="191" column="40" selection-start-line="191" selection-start-column="40" selection-end-line="191" selection-end-column="40" />
75
+                <state relative-caret-position="309">
76
+                  <caret line="191" column="43" lean-forward="true" selection-start-line="191" selection-start-column="43" selection-end-line="191" selection-end-column="43" />
82
                   <folding>
77
                   <folding>
83
                     <element signature="imports" expanded="true" />
78
                     <element signature="imports" expanded="true" />
84
                     <element signature="e#1970#1971#0" expanded="true" />
79
                     <element signature="e#1970#1971#0" expanded="true" />
169
         <option value="$PROJECT_DIR$/README.md" />
164
         <option value="$PROJECT_DIR$/README.md" />
170
         <option value="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" />
165
         <option value="$PROJECT_DIR$/arraz/src/main/java/OddEven.java" />
171
         <option value="$PROJECT_DIR$/arraz/src/main/java/MinMax.java" />
166
         <option value="$PROJECT_DIR$/arraz/src/main/java/MinMax.java" />
172
-        <option value="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" />
173
         <option value="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" />
167
         <option value="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" />
168
+        <option value="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" />
174
       </list>
169
       </list>
175
     </option>
170
     </option>
176
   </component>
171
   </component>
240
     <property name="GO_FMT" value="false" />
235
     <property name="GO_FMT" value="false" />
241
     <property name="WebServerToolWindowFactoryState" value="false" />
236
     <property name="WebServerToolWindowFactoryState" value="false" />
242
     <property name="aspect.path.notification.shown" value="true" />
237
     <property name="aspect.path.notification.shown" value="true" />
243
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544141205829" />
238
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544142316149" />
244
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
239
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
245
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
240
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
246
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
241
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
270
       </list>
265
       </list>
271
     </option>
266
     </option>
272
   </component>
267
   </component>
273
-  <component name="RunManager" selected="JUnit.ArrazTest.test1RemoveDupes">
268
+  <component name="RunManager" selected="JUnit.ArrazTest.test2RemoveDupes">
274
     <configuration default="true" type="Applet" factoryName="Applet">
269
     <configuration default="true" type="Applet" factoryName="Applet">
275
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
270
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
276
       <method v="2">
271
       <method v="2">
370
     </list>
365
     </list>
371
     <recent_temporary>
366
     <recent_temporary>
372
       <list>
367
       <list>
373
-        <item itemvalue="JUnit.ArrazTest.test1RemoveDupes" />
374
         <item itemvalue="JUnit.ArrazTest.test2RemoveDupes" />
368
         <item itemvalue="JUnit.ArrazTest.test2RemoveDupes" />
369
+        <item itemvalue="JUnit.ArrazTest.test1RemoveDupes" />
375
         <item itemvalue="JUnit.ArrazTest.test2FindMinMax" />
370
         <item itemvalue="JUnit.ArrazTest.test2FindMinMax" />
376
         <item itemvalue="JUnit.ArrazTest.test1FindMinMax" />
371
         <item itemvalue="JUnit.ArrazTest.test1FindMinMax" />
377
         <item itemvalue="JUnit.ArrazTest.test2InsertIntoArrayAt" />
372
         <item itemvalue="JUnit.ArrazTest.test2InsertIntoArrayAt" />
391
       <workItem from="1543955862749" duration="2347000" />
386
       <workItem from="1543955862749" duration="2347000" />
392
       <workItem from="1543958998826" duration="113000" />
387
       <workItem from="1543958998826" duration="113000" />
393
       <workItem from="1544020724645" duration="762000" />
388
       <workItem from="1544020724645" duration="762000" />
394
-      <workItem from="1544046527795" duration="13055000" />
389
+      <workItem from="1544046527795" duration="14260000" />
395
     </task>
390
     </task>
396
     <task id="LOCAL-00001" summary="readme and docs">
391
     <task id="LOCAL-00001" summary="readme and docs">
397
       <created>1544021313039</created>
392
       <created>1544021313039</created>
404
     <servers />
399
     <servers />
405
   </component>
400
   </component>
406
   <component name="TestHistory">
401
   <component name="TestHistory">
407
-    <history-entry file="ArrazTest_test1RemoveElement - 2018.12.06 at 17h 55m 05s.xml">
408
-      <configuration name="ArrazTest.test1RemoveElement" configurationId="JUnit" />
409
-    </history-entry>
410
-    <history-entry file="ArrazTest_test1RemoveElement - 2018.12.06 at 17h 55m 18s.xml">
411
-      <configuration name="ArrazTest.test1RemoveElement" configurationId="JUnit" />
412
-    </history-entry>
413
-    <history-entry file="ArrazTest_test2RemoveElement - 2018.12.06 at 17h 55m 21s.xml">
414
-      <configuration name="ArrazTest.test2RemoveElement" configurationId="JUnit" />
415
-    </history-entry>
416
     <history-entry file="ArrazTest_test1InsertIntoArrayAt - 2018.12.06 at 18h 23m 24s.xml">
402
     <history-entry file="ArrazTest_test1InsertIntoArrayAt - 2018.12.06 at 18h 23m 24s.xml">
417
       <configuration name="ArrazTest.test1InsertIntoArrayAt" configurationId="JUnit" />
403
       <configuration name="ArrazTest.test1InsertIntoArrayAt" configurationId="JUnit" />
418
     </history-entry>
404
     </history-entry>
434
     <history-entry file="ArrazTest_test2FindMinMax - 2018.12.06 at 18h 43m 45s.xml">
420
     <history-entry file="ArrazTest_test2FindMinMax - 2018.12.06 at 18h 43m 45s.xml">
435
       <configuration name="ArrazTest.test2FindMinMax" configurationId="JUnit" />
421
       <configuration name="ArrazTest.test2FindMinMax" configurationId="JUnit" />
436
     </history-entry>
422
     </history-entry>
423
+    <history-entry file="ArrazTest_test1RemoveDupes - 2018.12.06 at 19h 04m 59s.xml">
424
+      <configuration name="ArrazTest.test1RemoveDupes" configurationId="JUnit" />
425
+    </history-entry>
426
+    <history-entry file="ArrazTest_test2RemoveDupes - 2018.12.06 at 19h 05m 07s.xml">
427
+      <configuration name="ArrazTest.test2RemoveDupes" configurationId="JUnit" />
428
+    </history-entry>
429
+    <history-entry file="ArrazTest_test1RemoveDupes - 2018.12.06 at 19h 06m 41s.xml">
430
+      <configuration name="ArrazTest.test1RemoveDupes" configurationId="JUnit" />
431
+    </history-entry>
437
   </component>
432
   </component>
438
   <component name="TimeTrackingManager">
433
   <component name="TimeTrackingManager">
439
-    <option name="totallyTimeSpent" value="16277000" />
434
+    <option name="totallyTimeSpent" value="17482000" />
440
   </component>
435
   </component>
441
   <component name="ToolWindowManager">
436
   <component name="ToolWindowManager">
442
     <frame x="0" y="23" width="1440" height="805" extended-state="6" />
437
     <frame x="0" y="23" width="1440" height="805" extended-state="6" />
523
     </entry>
518
     </entry>
524
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
519
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
525
       <provider selected="true" editor-type-id="text-editor">
520
       <provider selected="true" editor-type-id="text-editor">
526
-        <state relative-caret-position="369">
527
-          <caret line="122" lean-forward="true" selection-start-line="122" selection-end-line="122" />
521
+        <state relative-caret-position="354">
522
+          <caret line="119" column="22" selection-start-line="119" selection-start-column="22" selection-end-line="119" selection-end-column="22" />
528
           <folding>
523
           <folding>
529
             <element signature="imports" expanded="true" />
524
             <element signature="imports" expanded="true" />
530
             <element signature="e#414#415#0" expanded="true" />
525
             <element signature="e#414#415#0" expanded="true" />
531
             <element signature="e#448#449#0" expanded="true" />
526
             <element signature="e#448#449#0" expanded="true" />
532
             <element signature="e#535#536#0" expanded="true" />
527
             <element signature="e#535#536#0" expanded="true" />
533
             <element signature="e#576#577#0" expanded="true" />
528
             <element signature="e#576#577#0" expanded="true" />
534
-            <element signature="e#2864#2873#0" expanded="true" />
535
             <element signature="e#2895#2904#0" expanded="true" />
529
             <element signature="e#2895#2904#0" expanded="true" />
536
           </folding>
530
           </folding>
537
         </state>
531
         </state>
539
     </entry>
533
     </entry>
540
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
534
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
541
       <provider selected="true" editor-type-id="text-editor">
535
       <provider selected="true" editor-type-id="text-editor">
542
-        <state relative-caret-position="372">
543
-          <caret line="191" column="40" selection-start-line="191" selection-start-column="40" selection-end-line="191" selection-end-column="40" />
536
+        <state relative-caret-position="309">
537
+          <caret line="191" column="43" lean-forward="true" selection-start-line="191" selection-start-column="43" selection-end-line="191" selection-end-column="43" />
544
           <folding>
538
           <folding>
545
             <element signature="imports" expanded="true" />
539
             <element signature="imports" expanded="true" />
546
             <element signature="e#1970#1971#0" expanded="true" />
540
             <element signature="e#1970#1971#0" expanded="true" />

+ 5
- 4
arraz/src/main/java/Arraz.java View File

109
     }
109
     }
110
 
110
 
111
     public Integer[] removeDupes(Integer[] arr) {
111
     public Integer[] removeDupes(Integer[] arr) {
112
-        ArrayList<Integer> result = new ArrayList<Integer>();
113
         Set<Integer> set = new HashSet<Integer>();
112
         Set<Integer> set = new HashSet<Integer>();
114
         for (Integer i : arr) {
113
         for (Integer i : arr) {
115
             set.add(i);
114
             set.add(i);
116
         }
115
         }
116
+        Integer[] result = new Integer[set.size()];
117
+        int counter = 0;
117
         for (Integer i: set) {
118
         for (Integer i: set) {
118
-            result.add(i);
119
+            result[counter]=i;
120
+            counter++;
119
         }
121
         }
120
-        Integer[] foo = (Integer[]) result.toArray();
121
-        return foo;
122
+        return result;
122
     }
123
     }
123
 }
124
 }

+ 3
- 0
arraz/src/test/java/ArrazTest.java View File

191
         arr = arraz.removeDupes(arr);
191
         arr = arraz.removeDupes(arr);
192
         Assert.assertEquals(arr.length, 5);
192
         Assert.assertEquals(arr.length, 5);
193
     }
193
     }
194
+
195
+    @Test
196
+    
194
 }
197
 }