Browse Source

final edits, cleaned up code

Connor Dunnigan 6 years ago
parent
commit
89a285c03e
2 changed files with 55 additions and 68 deletions
  1. 51
    58
      .idea/workspace.xml
  2. 4
    10
      src/main/java/MyMap.java

+ 51
- 58
.idea/workspace.xml View File

@@ -2,14 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="11ae2380-b501-43a2-a9ac-78d83deebe8d" name="Default Changelist" comment="">
5
-      <change afterPath="$PROJECT_DIR$/src/main/java/MyArrayList.java" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/src/main/java/MyMap.java" afterDir="false" />
7
-      <change afterPath="$PROJECT_DIR$/src/main/java/MySet.java" afterDir="false" />
8
-      <change afterPath="$PROJECT_DIR$/src/test/java/TestArrayList.java" afterDir="false" />
9
-      <change afterPath="$PROJECT_DIR$/src/test/java/TestMap.java" afterDir="false" />
10
-      <change afterPath="$PROJECT_DIR$/src/test/java/TestSet.java" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/src/main/java/.deleteme" beforeDir="false" />
12
-      <change beforePath="$PROJECT_DIR$/src/test/java/.deleteme" beforeDir="false" />
5
+      <change beforePath="$PROJECT_DIR$/src/main/java/MyMap.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MyMap.java" afterDir="false" />
13 6
     </list>
14 7
     <ignored path="$PROJECT_DIR$/target/" />
15 8
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -45,12 +38,12 @@
45 38
       <usages-collector id="statistics.file.extensions.edit">
46 39
         <counts>
47 40
           <entry key="dummy" value="28" />
48
-          <entry key="java" value="8107" />
41
+          <entry key="java" value="8130" />
49 42
         </counts>
50 43
       </usages-collector>
51 44
       <usages-collector id="statistics.file.types.edit">
52 45
         <counts>
53
-          <entry key="JAVA" value="8107" />
46
+          <entry key="JAVA" value="8130" />
54 47
           <entry key="PLAIN_TEXT" value="28" />
55 48
         </counts>
56 49
       </usages-collector>
@@ -63,8 +56,8 @@
63 56
           <file pinned="false" current-in-tab="true">
64 57
             <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
65 58
               <provider selected="true" editor-type-id="text-editor">
66
-                <state relative-caret-position="180">
67
-                  <caret line="103" column="39" selection-start-line="103" selection-start-column="39" selection-end-line="103" selection-end-column="39" />
59
+                <state relative-caret-position="745">
60
+                  <caret line="52" column="49" lean-forward="true" selection-start-line="52" selection-start-column="49" selection-end-line="52" selection-end-column="49" />
68 61
                 </state>
69 62
               </provider>
70 63
             </entry>
@@ -72,7 +65,7 @@
72 65
           <file pinned="false" current-in-tab="false">
73 66
             <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
74 67
               <provider selected="true" editor-type-id="text-editor">
75
-                <state relative-caret-position="-160">
68
+                <state relative-caret-position="-14">
76 69
                   <folding>
77 70
                     <element signature="imports" expanded="true" />
78 71
                   </folding>
@@ -83,8 +76,8 @@
83 76
           <file pinned="false" current-in-tab="false">
84 77
             <entry file="file://$PROJECT_DIR$/src/main/java/MyMap.java">
85 78
               <provider selected="true" editor-type-id="text-editor">
86
-                <state relative-caret-position="150">
87
-                  <caret line="10" column="5" selection-start-line="10" selection-start-column="5" selection-end-line="10" selection-end-column="5" />
79
+                <state relative-caret-position="585">
80
+                  <caret line="39" column="45" selection-start-line="39" selection-start-column="45" selection-end-line="39" selection-end-column="45" />
88 81
                 </state>
89 82
               </provider>
90 83
             </entry>
@@ -96,7 +89,7 @@
96 89
           <file pinned="false" current-in-tab="true">
97 90
             <entry file="file://$PROJECT_DIR$/src/test/java/TestArrayList.java">
98 91
               <provider selected="true" editor-type-id="text-editor">
99
-                <state relative-caret-position="-620">
92
+                <state relative-caret-position="405">
100 93
                   <caret line="27" column="5" selection-start-line="27" selection-start-column="5" selection-end-line="27" selection-end-column="5" />
101 94
                   <folding>
102 95
                     <element signature="imports" expanded="true" />
@@ -185,11 +178,11 @@
185 178
         <option value="$PROJECT_DIR$/src/main/java/ArrayList.java" />
186 179
         <option value="$PROJECT_DIR$/src/main/java/MyNewArrayList.java" />
187 180
         <option value="$PROJECT_DIR$/src/test/java/TestArrayList.java" />
188
-        <option value="$PROJECT_DIR$/src/main/java/MyMap.java" />
189 181
         <option value="$PROJECT_DIR$/src/test/java/TestSet.java" />
190 182
         <option value="$PROJECT_DIR$/src/main/java/MySet.java" />
191 183
         <option value="$PROJECT_DIR$/src/test/java/TestMap.java" />
192 184
         <option value="$PROJECT_DIR$/src/main/java/MyArrayList.java" />
185
+        <option value="$PROJECT_DIR$/src/main/java/MyMap.java" />
193 186
       </list>
194 187
     </option>
195 188
   </component>
@@ -350,26 +343,11 @@
350 343
       <option name="presentableId" value="Default" />
351 344
       <updated>1542237905466</updated>
352 345
       <workItem from="1542237907308" duration="25454000" />
353
-      <workItem from="1542390933928" duration="34652000" />
346
+      <workItem from="1542390933928" duration="35226000" />
354 347
     </task>
355 348
     <servers />
356 349
   </component>
357 350
   <component name="TestHistory">
358
-    <history-entry file="TestSet - 2018.11.17 at 13h 02m 01s.xml">
359
-      <configuration name="TestSet" configurationId="JUnit" />
360
-    </history-entry>
361
-    <history-entry file="TestSet - 2018.11.17 at 13h 03m 28s.xml">
362
-      <configuration name="TestSet" configurationId="JUnit" />
363
-    </history-entry>
364
-    <history-entry file="TestSet_testContainsAll - 2018.11.17 at 13h 05m 23s.xml">
365
-      <configuration name="TestSet.testContainsAll" configurationId="JUnit" />
366
-    </history-entry>
367
-    <history-entry file="TestSet - 2018.11.17 at 13h 05m 32s.xml">
368
-      <configuration name="TestSet" configurationId="JUnit" />
369
-    </history-entry>
370
-    <history-entry file="TestSet_testContainsAll - 2018.11.17 at 13h 18m 39s.xml">
371
-      <configuration name="TestSet.testContainsAll" configurationId="JUnit" />
372
-    </history-entry>
373 351
     <history-entry file="TestArrayList - 2018.11.17 at 13h 20m 08s.xml">
374 352
       <configuration name="TestArrayList" configurationId="JUnit" />
375 353
     </history-entry>
@@ -385,15 +363,30 @@
385 363
     <history-entry file="TestArrayList_testRemove - 2018.11.17 at 13h 28m 27s.xml">
386 364
       <configuration name="TestArrayList.testRemove" configurationId="JUnit" />
387 365
     </history-entry>
366
+    <history-entry file="TestArrayList_testRemove - 2018.11.17 at 13h 29m 27s.xml">
367
+      <configuration name="TestArrayList.testRemove" configurationId="JUnit" />
368
+    </history-entry>
369
+    <history-entry file="TestArrayList_testRemove - 2018.11.17 at 13h 29m 42s.xml">
370
+      <configuration name="TestArrayList.testRemove" configurationId="JUnit" />
371
+    </history-entry>
372
+    <history-entry file="TestArrayList_testRemove - 2018.11.17 at 13h 29m 56s.xml">
373
+      <configuration name="TestArrayList.testRemove" configurationId="JUnit" />
374
+    </history-entry>
375
+    <history-entry file="TestArrayList - 2018.11.17 at 13h 30m 38s.xml">
376
+      <configuration name="TestArrayList" configurationId="JUnit" />
377
+    </history-entry>
378
+    <history-entry file="All_in_generics - 2018.11.17 at 13h 30m 48s.xml">
379
+      <configuration name="All in generics" configurationId="JUnit" />
380
+    </history-entry>
388 381
   </component>
389 382
   <component name="TimeTrackingManager">
390
-    <option name="totallyTimeSpent" value="60106000" />
383
+    <option name="totallyTimeSpent" value="60680000" />
391 384
   </component>
392 385
   <component name="ToolWindowManager">
393 386
     <frame x="-336" y="-1055" width="1883" height="1055" extended-state="0" />
394 387
     <editor active="true" />
395 388
     <layout>
396
-      <window_info content_ui="combo" id="Project" order="0" weight="0.117870726" />
389
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.117870726" />
397 390
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
398 391
       <window_info id="Designer" order="2" />
399 392
       <window_info id="UI Designer" order="3" />
@@ -401,7 +394,7 @@
401 394
       <window_info anchor="bottom" id="Message" order="0" />
402 395
       <window_info anchor="bottom" id="Find" order="1" weight="0.32917964" />
403 396
       <window_info anchor="bottom" id="Run" order="2" weight="0.20872274" />
404
-      <window_info active="true" anchor="bottom" id="Debug" order="3" visible="true" weight="0.3748702" />
397
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.3748702" />
405 398
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
406 399
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
407 400
       <window_info anchor="bottom" id="TODO" order="6" />
@@ -457,22 +450,6 @@
457 450
         </state>
458 451
       </provider>
459 452
     </entry>
460
-    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
461
-      <provider selected="true" editor-type-id="text-editor">
462
-        <state relative-caret-position="-160">
463
-          <folding>
464
-            <element signature="imports" expanded="true" />
465
-          </folding>
466
-        </state>
467
-      </provider>
468
-    </entry>
469
-    <entry file="file://$PROJECT_DIR$/src/main/java/MyMap.java">
470
-      <provider selected="true" editor-type-id="text-editor">
471
-        <state relative-caret-position="150">
472
-          <caret line="10" column="5" selection-start-line="10" selection-start-column="5" selection-end-line="10" selection-end-column="5" />
473
-        </state>
474
-      </provider>
475
-    </entry>
476 453
     <entry file="file://$PROJECT_DIR$/src/test/java/TestMap.java">
477 454
       <provider selected="true" editor-type-id="text-editor">
478 455
         <state relative-caret-position="1125">
@@ -502,23 +479,39 @@
502 479
         </state>
503 480
       </provider>
504 481
     </entry>
505
-    <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
482
+    <entry file="file://$PROJECT_DIR$/src/test/java/TestArrayList.java">
506 483
       <provider selected="true" editor-type-id="text-editor">
507
-        <state relative-caret-position="180">
508
-          <caret line="103" column="39" selection-start-line="103" selection-start-column="39" selection-end-line="103" selection-end-column="39" />
484
+        <state relative-caret-position="405">
485
+          <caret line="27" column="5" selection-start-line="27" selection-start-column="5" selection-end-line="27" selection-end-column="5" />
486
+          <folding>
487
+            <element signature="imports" expanded="true" />
488
+          </folding>
509 489
         </state>
510 490
       </provider>
511 491
     </entry>
512
-    <entry file="file://$PROJECT_DIR$/src/test/java/TestArrayList.java">
492
+    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
513 493
       <provider selected="true" editor-type-id="text-editor">
514
-        <state relative-caret-position="-620">
515
-          <caret line="27" column="5" selection-start-line="27" selection-start-column="5" selection-end-line="27" selection-end-column="5" />
494
+        <state relative-caret-position="-14">
516 495
           <folding>
517 496
             <element signature="imports" expanded="true" />
518 497
           </folding>
519 498
         </state>
520 499
       </provider>
521 500
     </entry>
501
+    <entry file="file://$PROJECT_DIR$/src/main/java/MyMap.java">
502
+      <provider selected="true" editor-type-id="text-editor">
503
+        <state relative-caret-position="585">
504
+          <caret line="39" column="45" selection-start-line="39" selection-start-column="45" selection-end-line="39" selection-end-column="45" />
505
+        </state>
506
+      </provider>
507
+    </entry>
508
+    <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
509
+      <provider selected="true" editor-type-id="text-editor">
510
+        <state relative-caret-position="745">
511
+          <caret line="52" column="49" lean-forward="true" selection-start-line="52" selection-start-column="49" selection-end-line="52" selection-end-column="49" />
512
+        </state>
513
+      </provider>
514
+    </entry>
522 515
   </component>
523 516
   <component name="masterDetails">
524 517
     <states>

+ 4
- 10
src/main/java/MyMap.java View File

@@ -12,10 +12,6 @@ public class MyMap<K,V> {
12 12
 
13 13
     public int size() { return size; }
14 14
 
15
-    public void setSize(int size) { this.size = size; }
16
-
17
-    public void setValue(int index, V value) { values.set(index, value); }
18
-
19 15
     public boolean isEmpty() { return (size == 0); }
20 16
 
21 17
     public boolean containsKey(K key) { return (keySet.contains(key)); }
@@ -25,7 +21,7 @@ public class MyMap<K,V> {
25 21
     public void clear(){
26 22
         keySet.clear();
27 23
         values.clear();
28
-        setSize(0);
24
+        size = 0;
29 25
     }
30 26
 
31 27
     public V get(K key) {
@@ -39,11 +35,9 @@ public class MyMap<K,V> {
39 35
         if (!containsKey(key)) {
40 36
             keySet.add(key);
41 37
             values.add(value);
42
-            setSize(size + 1);
43
-        } else {
44
-            int index = keyIndex(key);
45
-            setValue(index, value);
46
-        }
38
+            size = size + 1;
39
+        } else
40
+            values.set(keyIndex(key), value);
47 41
     }
48 42
 
49 43
     public int keyIndex(K key) {