Browse Source

Curtis Cook's Generics Lab

curtiscook 6 years ago
parent
commit
1fc6a0ecbf
3 changed files with 350 additions and 77 deletions
  1. 152
    77
      .idea/workspace.xml
  2. 79
    0
      src/main/java/MyMap.java
  3. 119
    0
      src/test/java/MyMapTest.java

+ 152
- 77
.idea/workspace.xml View File

@@ -2,11 +2,9 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="3ed3acda-69e1-4d78-93ae-20c8468595b6" name="Default Changelist" comment="">
5
-      <change afterPath="$PROJECT_DIR$/.idea/codeStyles/codeStyleConfig.xml" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/src/main/java/MyArrayList.java" afterDir="false" />
7
-      <change afterPath="$PROJECT_DIR$/src/main/java/MySet.java" afterDir="false" />
8
-      <change afterPath="$PROJECT_DIR$/src/test/java/MyArrayListTest.java" afterDir="false" />
9
-      <change afterPath="$PROJECT_DIR$/src/test/java/MySetTest.java" afterDir="false" />
5
+      <change afterPath="$PROJECT_DIR$/src/main/java/MyMap.java" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/src/test/java/MyMapTest.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
10 8
     </list>
11 9
     <ignored path="$PROJECT_DIR$/target/" />
12 10
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -16,15 +14,68 @@
16 14
     <option name="LAST_RESOLUTION" value="IGNORE" />
17 15
   </component>
18 16
   <component name="CoverageDataManager">
19
-    <SUITE FILE_PATH="coverage/generics$All_in_generics.ic" NAME="All in generics Coverage Results" MODIFIED="1543449837404" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
17
+    <SUITE FILE_PATH="coverage/generics$All_in_generics.ic" NAME="All in generics Coverage Results" MODIFIED="1543607412603" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
20 18
     <SUITE FILE_PATH="coverage/generics$MySetTest.ic" NAME="MySetTest Coverage Results" MODIFIED="1543449822920" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
19
+    <SUITE FILE_PATH="coverage/generics$MyMapTest.ic" NAME="MyMapTest Coverage Results" MODIFIED="1543607401770" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
20
+    <SUITE FILE_PATH="coverage/generics$MyMapTest_containsKeyTest2.ic" NAME="MyMapTest.containsKeyTest2 Coverage Results" MODIFIED="1543500091403" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
21
+    <SUITE FILE_PATH="coverage/generics$MyMapTest_containsValueTest2.ic" NAME="MyMapTest.containsValueTest2 Coverage Results" MODIFIED="1543499994189" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
21 22
     <SUITE FILE_PATH="coverage/generics$MyArrayListTest.ic" NAME="MyArrayListTest Coverage Results" MODIFIED="1543445344664" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
22 23
   </component>
23 24
   <component name="CoverageViewManager">
24 25
     <option name="myElementSize" value="203" />
25 26
   </component>
26 27
   <component name="FileEditorManager">
27
-    <leaf />
28
+    <splitter split-orientation="horizontal" split-proportion="0.5">
29
+      <split-first>
30
+        <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
31
+          <file pinned="false" current-in-tab="true">
32
+            <entry file="file://$PROJECT_DIR$/src/test/java/MyMapTest.java">
33
+              <provider selected="true" editor-type-id="text-editor">
34
+                <state relative-caret-position="1230">
35
+                  <caret line="82" column="5" selection-start-line="82" selection-start-column="5" selection-end-line="82" selection-end-column="5" />
36
+                  <folding>
37
+                    <element signature="imports" expanded="true" />
38
+                  </folding>
39
+                </state>
40
+              </provider>
41
+            </entry>
42
+          </file>
43
+          <file pinned="false" current-in-tab="false">
44
+            <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
45
+              <provider selected="true" editor-type-id="text-editor">
46
+                <state relative-caret-position="285">
47
+                  <caret line="21" column="5" lean-forward="true" selection-start-line="21" selection-start-column="5" selection-end-line="21" selection-end-column="5" />
48
+                  <folding>
49
+                    <element signature="e#606#607#0" expanded="true" />
50
+                    <element signature="e#652#653#0" expanded="true" />
51
+                    <element signature="e#1335#1336#0" expanded="true" />
52
+                    <element signature="e#1373#1374#0" expanded="true" />
53
+                  </folding>
54
+                </state>
55
+              </provider>
56
+            </entry>
57
+          </file>
58
+        </leaf>
59
+      </split-first>
60
+      <split-second>
61
+        <leaf>
62
+          <file pinned="false" current-in-tab="true">
63
+            <entry file="file://$PROJECT_DIR$/src/main/java/MyMap.java">
64
+              <provider selected="true" editor-type-id="text-editor">
65
+                <state relative-caret-position="870">
66
+                  <caret line="60" column="9" lean-forward="true" selection-start-line="60" selection-start-column="9" selection-end-line="60" selection-end-column="9" />
67
+                  <folding>
68
+                    <element signature="e#987#988#0" expanded="true" />
69
+                    <element signature="e#1014#1015#0" expanded="true" />
70
+                    <element signature="e#1838#1839#0" expanded="true" />
71
+                  </folding>
72
+                </state>
73
+              </provider>
74
+            </entry>
75
+          </file>
76
+        </leaf>
77
+      </split-second>
78
+    </splitter>
28 79
   </component>
29 80
   <component name="FileTemplateManagerImpl">
30 81
     <option name="RECENT_TEMPLATES">
@@ -41,12 +92,14 @@
41 92
       <list>
42 93
         <option value="$PROJECT_DIR$/src/test/java/MyArrayListTest.java" />
43 94
         <option value="$PROJECT_DIR$/src/main/java/MyArrayList.java" />
44
-        <option value="$PROJECT_DIR$/src/main/java/MySet.java" />
45 95
         <option value="$PROJECT_DIR$/src/test/java/MySetTest.java" />
96
+        <option value="$PROJECT_DIR$/src/main/java/MySet.java" />
97
+        <option value="$PROJECT_DIR$/src/main/java/MyMap.java" />
98
+        <option value="$PROJECT_DIR$/src/test/java/MyMapTest.java" />
46 99
       </list>
47 100
     </option>
48 101
   </component>
49
-  <component name="ProjectFrameBounds" extendedState="6">
102
+  <component name="ProjectFrameBounds">
50 103
     <option name="y" value="23" />
51 104
     <option name="width" value="1440" />
52 105
     <option name="height" value="877" />
@@ -57,8 +110,6 @@
57 110
       <foldersAlwaysOnTop value="true" />
58 111
     </navigator>
59 112
     <panes>
60
-      <pane id="PackagesPane" />
61
-      <pane id="Scope" />
62 113
       <pane id="ProjectPane">
63 114
         <subPane>
64 115
           <expand>
@@ -101,12 +152,14 @@
101 152
           <select />
102 153
         </subPane>
103 154
       </pane>
155
+      <pane id="PackagesPane" />
156
+      <pane id="Scope" />
104 157
     </panes>
105 158
   </component>
106 159
   <component name="PropertiesComponent">
107 160
     <property name="WebServerToolWindowFactoryState" value="false" />
108 161
     <property name="aspect.path.notification.shown" value="true" />
109
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1543449848806" />
162
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1543607421084" />
110 163
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
111 164
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
112 165
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -136,39 +189,39 @@
136 189
         <option name="Make" enabled="true" />
137 190
       </method>
138 191
     </configuration>
139
-    <configuration name="MySetTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
192
+    <configuration name="MyMapTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
140 193
       <module name="generics" />
141 194
       <option name="PACKAGE_NAME" value="" />
142
-      <option name="MAIN_CLASS_NAME" value="MySetTest" />
195
+      <option name="MAIN_CLASS_NAME" value="MyMapTest" />
143 196
       <method v="2">
144 197
         <option name="Make" enabled="true" />
145 198
       </method>
146 199
     </configuration>
147
-    <configuration name="MySetTest.contains" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
200
+    <configuration name="MyMapTest.addTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
148 201
       <module name="generics" />
149 202
       <option name="PACKAGE_NAME" value="" />
150
-      <option name="MAIN_CLASS_NAME" value="MySetTest" />
151
-      <option name="METHOD_NAME" value="contains" />
203
+      <option name="MAIN_CLASS_NAME" value="MyMapTest" />
204
+      <option name="METHOD_NAME" value="addTest" />
152 205
       <option name="TEST_OBJECT" value="method" />
153 206
       <method v="2">
154 207
         <option name="Make" enabled="true" />
155 208
       </method>
156 209
     </configuration>
157
-    <configuration name="MySetTest.isEmptyTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
210
+    <configuration name="MyMapTest.getTest2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
158 211
       <module name="generics" />
159 212
       <option name="PACKAGE_NAME" value="" />
160
-      <option name="MAIN_CLASS_NAME" value="MySetTest" />
161
-      <option name="METHOD_NAME" value="isEmptyTest" />
213
+      <option name="MAIN_CLASS_NAME" value="MyMapTest" />
214
+      <option name="METHOD_NAME" value="getTest2" />
162 215
       <option name="TEST_OBJECT" value="method" />
163 216
       <method v="2">
164 217
         <option name="Make" enabled="true" />
165 218
       </method>
166 219
     </configuration>
167
-    <configuration name="MySetTest.removeTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
220
+    <configuration name="MyMapTest.putAndSizeTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
168 221
       <module name="generics" />
169 222
       <option name="PACKAGE_NAME" value="" />
170
-      <option name="MAIN_CLASS_NAME" value="MySetTest" />
171
-      <option name="METHOD_NAME" value="removeTest" />
223
+      <option name="MAIN_CLASS_NAME" value="MyMapTest" />
224
+      <option name="METHOD_NAME" value="putAndSizeTest" />
172 225
       <option name="TEST_OBJECT" value="method" />
173 226
       <method v="2">
174 227
         <option name="Make" enabled="true" />
@@ -177,10 +230,10 @@
177 230
     <recent_temporary>
178 231
       <list>
179 232
         <item itemvalue="JUnit.All in generics" />
180
-        <item itemvalue="JUnit.MySetTest" />
181
-        <item itemvalue="JUnit.MySetTest.contains" />
182
-        <item itemvalue="JUnit.MySetTest.removeTest" />
183
-        <item itemvalue="JUnit.MySetTest.isEmptyTest" />
233
+        <item itemvalue="JUnit.MyMapTest" />
234
+        <item itemvalue="JUnit.MyMapTest.getTest2" />
235
+        <item itemvalue="JUnit.MyMapTest.putAndSizeTest" />
236
+        <item itemvalue="JUnit.MyMapTest.addTest" />
184 237
       </list>
185 238
     </recent_temporary>
186 239
   </component>
@@ -195,60 +248,57 @@
195 248
       <option name="presentableId" value="Default" />
196 249
       <updated>1543341433134</updated>
197 250
       <workItem from="1543341434901" duration="18243000" />
251
+      <workItem from="1543450045411" duration="9186000" />
252
+      <workItem from="1543586625087" duration="4525000" />
198 253
     </task>
199 254
     <servers />
200 255
   </component>
201 256
   <component name="TestHistory">
202
-    <history-entry file="MySetTest_addTest2 - 2018.11.28 at 18h 20m 33s.xml">
203
-      <configuration name="MySetTest.addTest2" configurationId="JUnit" />
257
+    <history-entry file="MyMapTest_putAndSizeTest - 2018.11.30 at 14h 45m 34s.xml">
258
+      <configuration name="MyMapTest.putAndSizeTest" configurationId="JUnit" />
204 259
     </history-entry>
205
-    <history-entry file="MySetTest_clearTest - 2018.11.28 at 18h 23m 02s.xml">
206
-      <configuration name="MySetTest.clearTest" configurationId="JUnit" />
260
+    <history-entry file="MyMapTest_getTest2 - 2018.11.30 at 14h 45m 40s.xml">
261
+      <configuration name="MyMapTest.getTest2" configurationId="JUnit" />
207 262
     </history-entry>
208
-    <history-entry file="MySetTest_isEmptyTest - 2018.11.28 at 18h 25m 38s.xml">
209
-      <configuration name="MySetTest.isEmptyTest" configurationId="JUnit" />
263
+    <history-entry file="MyMapTest_putAndSizeTest - 2018.11.30 at 14h 48m 07s.xml">
264
+      <configuration name="MyMapTest.putAndSizeTest" configurationId="JUnit" />
210 265
     </history-entry>
211
-    <history-entry file="MySetTest_removeTest - 2018.11.28 at 18h 35m 21s.xml">
212
-      <configuration name="MySetTest.removeTest" configurationId="JUnit" />
266
+    <history-entry file="MyMapTest_getTest2 - 2018.11.30 at 14h 48m 14s.xml">
267
+      <configuration name="MyMapTest.getTest2" configurationId="JUnit" />
213 268
     </history-entry>
214
-    <history-entry file="MySetTest_removeTest - 2018.11.28 at 18h 35m 57s.xml">
215
-      <configuration name="MySetTest.removeTest" configurationId="JUnit" />
269
+    <history-entry file="MyMapTest_getTest2 - 2018.11.30 at 14h 49m 03s.xml">
270
+      <configuration name="MyMapTest.getTest2" configurationId="JUnit" />
216 271
     </history-entry>
217
-    <history-entry file="MySetTest - 2018.11.28 at 18h 37m 14s.xml">
218
-      <configuration name="MySetTest" configurationId="JUnit" />
272
+    <history-entry file="MyMapTest_putAndSizeTest - 2018.11.30 at 14h 49m 34s.xml">
273
+      <configuration name="MyMapTest.putAndSizeTest" configurationId="JUnit" />
219 274
     </history-entry>
220
-    <history-entry file="MySetTest_contains - 2018.11.28 at 18h 39m 15s.xml">
221
-      <configuration name="MySetTest.contains" configurationId="JUnit" />
275
+    <history-entry file="MyMapTest_putAndSizeTest - 2018.11.30 at 14h 49m 41s.xml">
276
+      <configuration name="MyMapTest.putAndSizeTest" configurationId="JUnit" />
222 277
     </history-entry>
223
-    <history-entry file="MySetTest - 2018.11.28 at 18h 39m 25s.xml">
224
-      <configuration name="MySetTest" configurationId="JUnit" />
278
+    <history-entry file="MyMapTest_getTest2 - 2018.11.30 at 14h 49m 49s.xml">
279
+      <configuration name="MyMapTest.getTest2" configurationId="JUnit" />
225 280
     </history-entry>
226
-    <history-entry file="MySetTest - 2018.11.28 at 19h 03m 46s.xml">
227
-      <configuration name="MySetTest" configurationId="JUnit" />
281
+    <history-entry file="MyMapTest - 2018.11.30 at 14h 50m 05s.xml">
282
+      <configuration name="MyMapTest" configurationId="JUnit" />
228 283
     </history-entry>
229
-    <history-entry file="All_in_generics - 2018.11.28 at 19h 04m 00s.xml">
284
+    <history-entry file="All_in_generics - 2018.11.30 at 14h 50m 16s.xml">
230 285
       <configuration name="All in generics" configurationId="JUnit" />
231 286
     </history-entry>
232 287
   </component>
233 288
   <component name="TimeTrackingManager">
234
-    <option name="totallyTimeSpent" value="18243000" />
289
+    <option name="totallyTimeSpent" value="31954000" />
235 290
   </component>
236 291
   <component name="ToolWindowManager">
237
-    <frame x="0" y="23" width="1440" height="877" extended-state="6" />
292
+    <frame x="0" y="23" width="1440" height="877" extended-state="0" />
293
+    <editor active="true" />
238 294
     <layout>
239
-      <window_info id="Designer" />
240
-      <window_info id="Image Layers" />
241
-      <window_info id="Capture Tool" />
242
-      <window_info id="UI Designer" />
243
-      <window_info id="Favorites" side_tool="true" />
244
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
295
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2532189" />
245 296
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
246
-      <window_info anchor="bottom" id="Terminal" />
247
-      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
248
-      <window_info anchor="bottom" id="Event Log" side_tool="true" />
249
-      <window_info anchor="bottom" id="Database Changes" />
250
-      <window_info anchor="bottom" id="Version Control" />
251
-      <window_info anchor="bottom" id="Messages" weight="0.3299363" />
297
+      <window_info id="Designer" order="2" />
298
+      <window_info id="Image Layers" order="3" />
299
+      <window_info id="Capture Tool" order="4" />
300
+      <window_info id="UI Designer" order="5" />
301
+      <window_info id="Favorites" order="6" side_tool="true" />
252 302
       <window_info anchor="bottom" id="Message" order="0" />
253 303
       <window_info anchor="bottom" id="Find" order="1" />
254 304
       <window_info anchor="bottom" id="Run" order="2" weight="0.3299363" />
@@ -256,16 +306,22 @@
256 306
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
257 307
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
258 308
       <window_info anchor="bottom" id="TODO" order="6" />
259
-      <window_info anchor="right" id="Maven" />
260
-      <window_info anchor="right" id="Palette" />
261
-      <window_info anchor="right" id="Capture Analysis" />
262
-      <window_info anchor="right" id="Database" />
263
-      <window_info anchor="right" id="Palette&#9;" />
264
-      <window_info anchor="right" id="Theme Preview" />
265
-      <window_info anchor="right" id="Coverage" side_tool="true" weight="0.3297568" />
309
+      <window_info anchor="bottom" id="Terminal" order="7" />
310
+      <window_info anchor="bottom" id="Docker" order="8" show_stripe_button="false" />
311
+      <window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
312
+      <window_info anchor="bottom" id="Messages" order="10" weight="0.3299363" />
313
+      <window_info anchor="bottom" id="Database Changes" order="11" />
314
+      <window_info anchor="bottom" id="Version Control" order="12" />
266 315
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
267 316
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
268 317
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
318
+      <window_info anchor="right" id="Maven" order="3" />
319
+      <window_info anchor="right" id="Palette" order="4" />
320
+      <window_info anchor="right" id="Capture Analysis" order="5" />
321
+      <window_info anchor="right" id="Database" order="6" />
322
+      <window_info anchor="right" id="Palette&#9;" order="7" />
323
+      <window_info anchor="right" id="Theme Preview" order="8" />
324
+      <window_info anchor="right" id="Coverage" order="9" side_tool="true" weight="0.3297568" />
269 325
     </layout>
270 326
   </component>
271 327
   <component name="TypeScriptGeneratedFilesManager">
@@ -308,7 +364,7 @@
308 364
           </nodes>
309 365
           <notes />
310 366
           <edges />
311
-          <settings layout="Hierarchic Group" zoom="0.8377425044091711" x="255.5" y="273.5" />
367
+          <settings layout="Hierarchic Group" zoom="0.8377425044091711" x="256.0" y="274.0" />
312 368
           <SelectedNodes />
313 369
           <Categories />
314 370
           <SCOPE>All</SCOPE>
@@ -326,7 +382,7 @@
326 382
           </nodes>
327 383
           <notes />
328 384
           <edges />
329
-          <settings layout="Hierarchic Group" zoom="1.0" x="60.5" y="14.5" />
385
+          <settings layout="Hierarchic Group" zoom="1.0" x="61.0" y="15.0" />
330 386
           <SelectedNodes />
331 387
           <Categories />
332 388
           <SCOPE>All</SCOPE>
@@ -356,8 +412,8 @@
356 412
     </entry>
357 413
     <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
358 414
       <provider selected="true" editor-type-id="text-editor">
359
-        <state relative-caret-position="-661">
360
-          <caret line="13" column="8" lean-forward="true" selection-start-line="13" selection-start-column="8" selection-end-line="13" selection-end-column="8" />
415
+        <state relative-caret-position="-203">
416
+          <caret line="13" column="8" selection-start-line="13" selection-start-column="8" selection-end-line="13" selection-end-column="8" />
361 417
           <folding>
362 418
             <element signature="e#83#84#0" expanded="true" />
363 419
             <element signature="e#129#130#0" expanded="true" />
@@ -371,20 +427,39 @@
371 427
     </entry>
372 428
     <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
373 429
       <provider selected="true" editor-type-id="text-editor">
374
-        <state relative-caret-position="598">
375
-          <caret line="49" column="20" lean-forward="true" selection-start-line="49" selection-start-column="20" selection-end-line="49" selection-end-column="20" />
430
+        <state relative-caret-position="285">
431
+          <caret line="21" column="5" lean-forward="true" selection-start-line="21" selection-start-column="5" selection-end-line="21" selection-end-column="5" />
376 432
           <folding>
377
-            <element signature="e#87#88#0" expanded="true" />
378
-            <element signature="e#127#128#0" expanded="true" />
379 433
             <element signature="e#606#607#0" expanded="true" />
380 434
             <element signature="e#652#653#0" expanded="true" />
381
-            <element signature="e#891#892#0" expanded="true" />
382
-            <element signature="e#934#935#0" expanded="true" />
435
+            <element signature="e#1335#1336#0" expanded="true" />
383 436
             <element signature="e#1373#1374#0" expanded="true" />
384 437
           </folding>
385 438
         </state>
386 439
       </provider>
387 440
     </entry>
441
+    <entry file="file://$PROJECT_DIR$/src/test/java/MyMapTest.java">
442
+      <provider selected="true" editor-type-id="text-editor">
443
+        <state relative-caret-position="1230">
444
+          <caret line="82" column="5" selection-start-line="82" selection-start-column="5" selection-end-line="82" selection-end-column="5" />
445
+          <folding>
446
+            <element signature="imports" expanded="true" />
447
+          </folding>
448
+        </state>
449
+      </provider>
450
+    </entry>
451
+    <entry file="file://$PROJECT_DIR$/src/main/java/MyMap.java">
452
+      <provider selected="true" editor-type-id="text-editor">
453
+        <state relative-caret-position="870">
454
+          <caret line="60" column="9" lean-forward="true" selection-start-line="60" selection-start-column="9" selection-end-line="60" selection-end-column="9" />
455
+          <folding>
456
+            <element signature="e#987#988#0" expanded="true" />
457
+            <element signature="e#1014#1015#0" expanded="true" />
458
+            <element signature="e#1838#1839#0" expanded="true" />
459
+          </folding>
460
+        </state>
461
+      </provider>
462
+    </entry>
388 463
   </component>
389 464
   <component name="masterDetails">
390 465
     <states>

+ 79
- 0
src/main/java/MyMap.java View File

@@ -0,0 +1,79 @@
1
+public class MyMap<E> {
2
+
3
+    private E[] keys;
4
+    private E[] values;
5
+
6
+
7
+    public MyMap() {
8
+        keys = (E[]) new Object[0];
9
+        values = (E[]) new Object[0];
10
+    }
11
+
12
+    public void clear() {
13
+        keys = (E[]) new Object[0];
14
+        values = (E[]) new Object[0];
15
+    }
16
+
17
+    public boolean containsKey(Object key) {
18
+        for (E element : keys) {
19
+            if (element.equals(key)) {
20
+                return true;
21
+            }
22
+        }
23
+        return false;
24
+    }
25
+
26
+    public boolean containsValue(Object value) {
27
+        for (E element : values) {
28
+            if (element.equals(value)) {
29
+                return true;
30
+            }
31
+        }
32
+        return false;
33
+    }
34
+
35
+    public E get(Object key) {
36
+        for (int i = 0; i < keys.length; i++) {
37
+            if (keys[i].equals(key)) {
38
+                return values[i];
39
+            }
40
+        }
41
+        return null;
42
+    }
43
+
44
+    public boolean isEmpty() {
45
+        return keys.length == 0;
46
+    }
47
+
48
+    public E[] keySet() {
49
+        return keys;
50
+    }
51
+
52
+    public E put(E key, E value) {
53
+        E originalValue = null;
54
+
55
+        for (int i = 0; i < keys.length; i++) {
56
+            if (keys[i].equals(key)) {
57
+                originalValue = values[i];
58
+                values[i] = value;
59
+                return originalValue;
60
+            }
61
+        }
62
+
63
+        E[] updatedKeys = (E[]) new Object[keys.length + 1];
64
+        E[] updatedValues = (E[]) new Object[values.length + 1];
65
+        for (int i = 0; i < keys.length; i++) {
66
+            updatedKeys[i] = keys[i];
67
+            updatedValues[i] = values[i];
68
+        }
69
+        updatedKeys[updatedKeys.length - 1] = key;
70
+        updatedValues[updatedValues.length - 1] = value;
71
+        keys = updatedKeys;
72
+        values = updatedValues;
73
+        return originalValue;
74
+    }
75
+
76
+    public int size() {
77
+        return keys.length;
78
+    }
79
+}

+ 119
- 0
src/test/java/MyMapTest.java View File

@@ -0,0 +1,119 @@
1
+import org.junit.Assert;
2
+import org.junit.Test;
3
+
4
+public class MyMapTest {
5
+
6
+    @Test
7
+    public void clearTest() {
8
+        MyMap myMap = new MyMap();
9
+        myMap.put("Curtis", 37);
10
+        myMap.put("Ashley", 30);
11
+        myMap.put("Caleb", 8);
12
+        myMap.put("Liam", 3);
13
+        myMap.clear();
14
+
15
+        int actual = myMap.size();
16
+
17
+        Assert.assertEquals(0, actual);
18
+    }
19
+
20
+    @Test
21
+    public void containsKeyTest1() {
22
+        MyMap myMap = new MyMap();
23
+        myMap.put("Curtis", 37);
24
+        myMap.put("Ashley", 30);
25
+        myMap.put("Caleb", 8);
26
+        myMap.put("Liam", 3);
27
+
28
+        boolean actual = myMap.containsKey("Caleb");
29
+
30
+        Assert.assertEquals(true, actual);
31
+    }
32
+
33
+    @Test
34
+    public void containsKeyTest2() {
35
+        MyMap myMap = new MyMap();
36
+        myMap.put("Curtis", 37);
37
+        myMap.put("Ashley", 30);
38
+        myMap.put("Caleb", 8);
39
+        myMap.put("Liam", 3);
40
+
41
+        boolean actual = myMap.containsKey("Lionel");
42
+
43
+        Assert.assertEquals(false, actual);
44
+    }
45
+
46
+    @Test
47
+    public void containsValueTest1() {
48
+        MyMap myMap = new MyMap();
49
+        myMap.put("Curtis", 37);
50
+        myMap.put("Ashley", 30);
51
+        myMap.put("Caleb", 8);
52
+        myMap.put("Liam", 3);
53
+
54
+        boolean actual = myMap.containsValue(30);
55
+
56
+        Assert.assertEquals(true, actual);
57
+    }
58
+
59
+    @Test
60
+    public void containsValueTest2() {
61
+        MyMap myMap = new MyMap();
62
+        myMap.put("Curtis", 37);
63
+        myMap.put("Ashley", 30);
64
+        myMap.put("Caleb", 8);
65
+        myMap.put("Liam", 3);
66
+
67
+        boolean actual = myMap.containsValue(40);
68
+
69
+        Assert.assertEquals(false, actual);
70
+    }
71
+
72
+    @Test
73
+    public void getTest1() {
74
+        MyMap myMap = new MyMap();
75
+        myMap.put("Curtis", 37);
76
+        myMap.put("Ashley", 30);
77
+        myMap.put("Caleb", 8);
78
+        myMap.put("Liam", 3);
79
+
80
+        int actual = (int) myMap.get("Caleb");
81
+
82
+        Assert.assertEquals(8, actual);
83
+    }
84
+
85
+    @Test
86
+    public void isEmptyTest() {
87
+        MyMap myMap = new MyMap();
88
+
89
+        boolean actual = myMap.isEmpty();
90
+
91
+        Assert.assertEquals(true, actual);
92
+    }
93
+
94
+    @Test
95
+    public void keySetTest() {
96
+        MyMap myMap = new MyMap();
97
+        myMap.put("Curtis", 37);
98
+        myMap.put("Ashley", 30);
99
+        myMap.put("Caleb", 8);
100
+        myMap.put("Liam", 3);
101
+
102
+        Object[] actual = myMap.keySet();
103
+
104
+        Assert.assertEquals(4, actual.length);
105
+    }
106
+
107
+    @Test
108
+    public void putAndSizeTest() {
109
+        MyMap myMap = new MyMap();
110
+        myMap.put("Curtis", 37);
111
+        myMap.put("Ashley", 30);
112
+        myMap.put("Curtis", 3);
113
+        myMap.put("Ashley", 3);
114
+
115
+        int actual = myMap.size();
116
+
117
+        Assert.assertEquals(2, actual);
118
+    }
119
+}