Przeglądaj źródła

MyArrayList - Complete

Nick Satinover 6 lat temu
rodzic
commit
8b4703d7c7
3 zmienionych plików z 201 dodań i 107 usunięć
  1. 108
    102
      .idea/workspace.xml
  2. 25
    5
      src/main/java/MySet.java
  3. 68
    0
      src/test/java/MySetTest.java

+ 108
- 102
.idea/workspace.xml Wyświetl plik

@@ -51,15 +51,15 @@
51 51
       </usages-collector>
52 52
       <usages-collector id="statistics.file.extensions.edit">
53 53
         <counts>
54
-          <entry key="java" value="3136" />
55
-          <entry key="txt" value="123" />
54
+          <entry key="java" value="3314" />
55
+          <entry key="txt" value="125" />
56 56
           <entry key="xml" value="2" />
57 57
         </counts>
58 58
       </usages-collector>
59 59
       <usages-collector id="statistics.file.types.edit">
60 60
         <counts>
61
-          <entry key="JAVA" value="3136" />
62
-          <entry key="PLAIN_TEXT" value="123" />
61
+          <entry key="JAVA" value="3314" />
62
+          <entry key="PLAIN_TEXT" value="125" />
63 63
           <entry key="XML" value="2" />
64 64
         </counts>
65 65
       </usages-collector>
@@ -72,8 +72,8 @@
72 72
           <file pinned="false" current-in-tab="true">
73 73
             <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
74 74
               <provider selected="true" editor-type-id="text-editor">
75
-                <state relative-caret-position="101">
76
-                  <caret line="166" column="18" lean-forward="true" selection-start-line="161" selection-start-column="19" selection-end-line="161" selection-end-column="28" />
75
+                <state relative-caret-position="535">
76
+                  <caret line="207" column="15" selection-start-line="207" selection-start-column="15" selection-end-line="207" selection-end-column="15" />
77 77
                   <folding>
78 78
                     <element signature="imports" expanded="true" />
79 79
                     <element signature="e#244#245#0" expanded="true" />
@@ -84,10 +84,8 @@
84 84
                     <element signature="e#1169#1170#0" expanded="true" />
85 85
                     <element signature="e#1222#1223#0" expanded="true" />
86 86
                     <element signature="e#1280#1281#0" expanded="true" />
87
-                    <element signature="e#3063#3064#0" expanded="true" />
88
-                    <element signature="e#3091#3092#0" expanded="true" />
89
-                    <element signature="e#3153#3154#0" expanded="true" />
90
-                    <element signature="e#3181#3182#0" expanded="true" />
87
+                    <element signature="e#5057#5058#0" expanded="true" />
88
+                    <element signature="e#5085#5086#0" expanded="true" />
91 89
                   </folding>
92 90
                 </state>
93 91
               </provider>
@@ -96,8 +94,8 @@
96 94
           <file pinned="false" current-in-tab="false">
97 95
             <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/Set.java">
98 96
               <provider selected="true" editor-type-id="text-editor">
99
-                <state relative-caret-position="61">
100
-                  <caret line="308" column="65" selection-start-line="308" selection-start-column="56" selection-end-line="308" selection-end-column="65" />
97
+                <state relative-caret-position="238">
98
+                  <caret line="272" column="23" selection-start-line="272" selection-start-column="12" selection-end-line="272" selection-end-column="23" />
101 99
                 </state>
102 100
               </provider>
103 101
             </entry>
@@ -109,8 +107,8 @@
109 107
           <file pinned="false" current-in-tab="true">
110 108
             <entry file="file://$PROJECT_DIR$/src/test/java/MySetTest.java">
111 109
               <provider selected="true" editor-type-id="text-editor">
112
-                <state relative-caret-position="304">
113
-                  <caret line="278" column="5" lean-forward="true" selection-start-line="278" selection-start-column="5" selection-end-line="278" selection-end-column="5" />
110
+                <state relative-caret-position="459">
111
+                  <caret line="157" column="15" selection-start-line="157" selection-start-column="15" selection-end-line="157" selection-end-column="15" />
114 112
                   <folding>
115 113
                     <element signature="imports" expanded="true" />
116 114
                     <element signature="e#1474#1480#0" expanded="true" />
@@ -119,6 +117,7 @@
119 117
                     <element signature="e#2583#2591#0" expanded="true" />
120 118
                     <element signature="e#2969#2977#0" expanded="true" />
121 119
                     <element signature="e#3343#3349#0" expanded="true" />
120
+                    <element signature="e#4161#4167#0" expanded="true" />
122 121
                     <element signature="e#4305#4313#0" expanded="true" />
123 122
                     <element signature="e#4764#4772#0" expanded="true" />
124 123
                     <element signature="e#5216#5224#0" expanded="true" />
@@ -126,6 +125,9 @@
126 125
                     <element signature="e#6095#6101#0" expanded="true" />
127 126
                     <element signature="e#6641#6647#0" expanded="true" />
128 127
                     <element signature="e#7059#7065#0" expanded="true" />
128
+                    <element signature="e#7536#7544#0" expanded="true" />
129
+                    <element signature="e#8053#8061#0" expanded="true" />
130
+                    <element signature="e#8540#8548#0" expanded="true" />
129 131
                   </folding>
130 132
                 </state>
131 133
               </provider>
@@ -165,8 +167,9 @@
165 167
       <find>iterator</find>
166 168
       <find>iter</find>
167 169
       <find>removeAll</find>
168
-      <find>toArray</find>
169 170
       <find>retainAll</find>
171
+      <find>toArray</find>
172
+      <find>containsAll</find>
170 173
     </findStrings>
171 174
   </component>
172 175
   <component name="Git.Settings">
@@ -198,9 +201,10 @@
198 201
     </option>
199 202
   </component>
200 203
   <component name="ProjectFrameBounds" extendedState="6">
201
-    <option name="y" value="23" />
202
-    <option name="width" value="1280" />
203
-    <option name="height" value="709" />
204
+    <option name="x" value="-309" />
205
+    <option name="y" value="-1057" />
206
+    <option name="width" value="1920" />
207
+    <option name="height" value="1057" />
204 208
   </component>
205 209
   <component name="ProjectLevelVcsManager" settingsEditedManually="true">
206 210
     <ConfirmationsSetting value="2" id="Add" />
@@ -259,7 +263,7 @@
259 263
   <component name="PropertiesComponent">
260 264
     <property name="WebServerToolWindowFactoryState" value="false" />
261 265
     <property name="aspect.path.notification.shown" value="true" />
262
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542381039515" />
266
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542390917194" />
263 267
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
264 268
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
265 269
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -277,55 +281,57 @@
277 281
       </list>
278 282
     </option>
279 283
   </component>
280
-  <component name="RunManager" selected="JUnit.MySetTest.removeAlllIntegerBooleanTest">
284
+  <component name="RunManager" selected="JUnit.MySetTest.containsAllLongBooleanTest">
281 285
     <configuration default="true" type="Application" factoryName="Application" show_console_on_std_err="true" show_console_on_std_out="true">
282 286
       <method v="2">
283 287
         <option name="Make" enabled="true" />
284 288
       </method>
285 289
     </configuration>
286
-    <configuration name="MySetTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
290
+    <configuration name="MySetTest.containsAllLongBooleanTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
287 291
       <module name="generics" />
288 292
       <option name="PACKAGE_NAME" value="" />
289 293
       <option name="MAIN_CLASS_NAME" value="MySetTest" />
294
+      <option name="METHOD_NAME" value="containsAllLongBooleanTest" />
295
+      <option name="TEST_OBJECT" value="method" />
290 296
       <method v="2">
291 297
         <option name="Make" enabled="true" />
292 298
       </method>
293 299
     </configuration>
294
-    <configuration name="MySetTest.isEmptyLongTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
300
+    <configuration name="MySetTest.removeAllLongBooleanTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
295 301
       <module name="generics" />
296 302
       <option name="PACKAGE_NAME" value="" />
297 303
       <option name="MAIN_CLASS_NAME" value="MySetTest" />
298
-      <option name="METHOD_NAME" value="isEmptyLongTest" />
304
+      <option name="METHOD_NAME" value="removeAllLongBooleanTest" />
299 305
       <option name="TEST_OBJECT" value="method" />
300 306
       <method v="2">
301 307
         <option name="Make" enabled="true" />
302 308
       </method>
303 309
     </configuration>
304
-    <configuration name="MySetTest.isEmptyLongTest2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
310
+    <configuration name="MySetTest.retainAllStringBooleanTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
305 311
       <module name="generics" />
306 312
       <option name="PACKAGE_NAME" value="" />
307 313
       <option name="MAIN_CLASS_NAME" value="MySetTest" />
308
-      <option name="METHOD_NAME" value="isEmptyLongTest2" />
314
+      <option name="METHOD_NAME" value="retainAllStringBooleanTest" />
309 315
       <option name="TEST_OBJECT" value="method" />
310 316
       <method v="2">
311 317
         <option name="Make" enabled="true" />
312 318
       </method>
313 319
     </configuration>
314
-    <configuration name="MySetTest.removeAllLongTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
320
+    <configuration name="MySetTest.retainAllStringBooleanTest1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
315 321
       <module name="generics" />
316 322
       <option name="PACKAGE_NAME" value="" />
317 323
       <option name="MAIN_CLASS_NAME" value="MySetTest" />
318
-      <option name="METHOD_NAME" value="removeAllLongTest" />
324
+      <option name="METHOD_NAME" value="retainAllStringBooleanTest1" />
319 325
       <option name="TEST_OBJECT" value="method" />
320 326
       <method v="2">
321 327
         <option name="Make" enabled="true" />
322 328
       </method>
323 329
     </configuration>
324
-    <configuration name="MySetTest.removeAlllIntegerBooleanTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
330
+    <configuration name="MySetTest.retainAllStringTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
325 331
       <module name="generics" />
326 332
       <option name="PACKAGE_NAME" value="" />
327 333
       <option name="MAIN_CLASS_NAME" value="MySetTest" />
328
-      <option name="METHOD_NAME" value="removeAlllIntegerBooleanTest" />
334
+      <option name="METHOD_NAME" value="retainAllStringTest" />
329 335
       <option name="TEST_OBJECT" value="method" />
330 336
       <method v="2">
331 337
         <option name="Make" enabled="true" />
@@ -355,19 +361,19 @@
355 361
       <method v="2" />
356 362
     </configuration>
357 363
     <list>
358
-      <item itemvalue="JUnit.MySetTest" />
359
-      <item itemvalue="JUnit.MySetTest.isEmptyLongTest" />
360
-      <item itemvalue="JUnit.MySetTest.isEmptyLongTest2" />
361
-      <item itemvalue="JUnit.MySetTest.removeAllLongTest" />
362
-      <item itemvalue="JUnit.MySetTest.removeAlllIntegerBooleanTest" />
364
+      <item itemvalue="JUnit.MySetTest.removeAllLongBooleanTest" />
365
+      <item itemvalue="JUnit.MySetTest.retainAllStringTest" />
366
+      <item itemvalue="JUnit.MySetTest.retainAllStringBooleanTest" />
367
+      <item itemvalue="JUnit.MySetTest.retainAllStringBooleanTest1" />
368
+      <item itemvalue="JUnit.MySetTest.containsAllLongBooleanTest" />
363 369
     </list>
364 370
     <recent_temporary>
365 371
       <list>
366
-        <item itemvalue="JUnit.MySetTest.removeAlllIntegerBooleanTest" />
367
-        <item itemvalue="JUnit.MySetTest.removeAllLongTest" />
368
-        <item itemvalue="JUnit.MySetTest.isEmptyLongTest2" />
369
-        <item itemvalue="JUnit.MySetTest.isEmptyLongTest" />
370
-        <item itemvalue="JUnit.MySetTest" />
372
+        <item itemvalue="JUnit.MySetTest.containsAllLongBooleanTest" />
373
+        <item itemvalue="JUnit.MySetTest.retainAllStringBooleanTest1" />
374
+        <item itemvalue="JUnit.MySetTest.retainAllStringBooleanTest" />
375
+        <item itemvalue="JUnit.MySetTest.retainAllStringTest" />
376
+        <item itemvalue="JUnit.MySetTest.removeAllLongBooleanTest" />
371 377
       </list>
372 378
     </recent_temporary>
373 379
   </component>
@@ -385,7 +391,7 @@
385 391
       <workItem from="1542145228816" duration="418000" />
386 392
       <workItem from="1542165623771" duration="4833000" />
387 393
       <workItem from="1542225031291" duration="12159000" />
388
-      <workItem from="1542293882069" duration="21109000" />
394
+      <workItem from="1542293882069" duration="22947000" />
389 395
     </task>
390 396
     <task id="LOCAL-00001" summary="MyArrayList&#10;Get, Add">
391 397
       <created>1542167642899</created>
@@ -471,43 +477,50 @@
471 477
       <option name="project" value="LOCAL" />
472 478
       <updated>1542324001221</updated>
473 479
     </task>
474
-    <option name="localTasksCounter" value="13" />
480
+    <task id="LOCAL-00013" summary="MyArrayList - Complete&#10;MySet - Working&#10;add, otherAdd get, contains, remove, addAll, clear, iterator, removeAll">
481
+      <created>1542381338323</created>
482
+      <option name="number" value="00013" />
483
+      <option name="presentableId" value="LOCAL-00013" />
484
+      <option name="project" value="LOCAL" />
485
+      <updated>1542381338323</updated>
486
+    </task>
487
+    <option name="localTasksCounter" value="14" />
475 488
     <servers />
476 489
   </component>
477 490
   <component name="TestHistory">
478
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 47m 19s.xml">
479
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
491
+    <history-entry file="MySetTest_removeAlllIntegerBooleanTest - 2018.11.16 at 10h 10m 31s.xml">
492
+      <configuration name="MySetTest.removeAlllIntegerBooleanTest" configurationId="JUnit" />
480 493
     </history-entry>
481
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 52m 53s.xml">
482
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
494
+    <history-entry file="MySetTest_removeAlllIntegerBooleanTest - 2018.11.16 at 10h 10m 41s.xml">
495
+      <configuration name="MySetTest.removeAlllIntegerBooleanTest" configurationId="JUnit" />
483 496
     </history-entry>
484
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 53m 35s.xml">
485
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
497
+    <history-entry file="MySetTest_removeAllLongBooleanTest - 2018.11.16 at 12h 37m 41s.xml">
498
+      <configuration name="MySetTest.removeAllLongBooleanTest" configurationId="JUnit" />
486 499
     </history-entry>
487
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 53m 38s.xml">
488
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
500
+    <history-entry file="MySetTest_removeAllLongBooleanTest - 2018.11.16 at 12h 38m 03s.xml">
501
+      <configuration name="MySetTest.removeAllLongBooleanTest" configurationId="JUnit" />
489 502
     </history-entry>
490
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 56m 12s.xml">
491
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
503
+    <history-entry file="MySetTest_retainAllStringTest - 2018.11.16 at 12h 47m 31s.xml">
504
+      <configuration name="MySetTest.retainAllStringTest" configurationId="JUnit" />
492 505
     </history-entry>
493
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 56m 31s.xml">
494
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
506
+    <history-entry file="MySetTest_retainAllStringTest - 2018.11.16 at 12h 47m 56s.xml">
507
+      <configuration name="MySetTest.retainAllStringTest" configurationId="JUnit" />
495 508
     </history-entry>
496
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 58m 37s.xml">
497
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
509
+    <history-entry file="MySetTest_retainAllStringBooleanTest - 2018.11.16 at 12h 49m 25s.xml">
510
+      <configuration name="MySetTest.retainAllStringBooleanTest" configurationId="JUnit" />
498 511
     </history-entry>
499
-    <history-entry file="MySetTest_removeAllLongTest - 2018.11.16 at 09h 58m 47s.xml">
500
-      <configuration name="MySetTest.removeAllLongTest" configurationId="JUnit" />
512
+    <history-entry file="MySetTest_retainAllStringBooleanTest - 2018.11.16 at 12h 49m 52s.xml">
513
+      <configuration name="MySetTest.retainAllStringBooleanTest" configurationId="JUnit" />
501 514
     </history-entry>
502
-    <history-entry file="MySetTest_removeAlllIntegerBooleanTest - 2018.11.16 at 10h 10m 31s.xml">
503
-      <configuration name="MySetTest.removeAlllIntegerBooleanTest" configurationId="JUnit" />
515
+    <history-entry file="MySetTest_retainAllStringBooleanTest1 - 2018.11.16 at 12h 50m 16s.xml">
516
+      <configuration name="MySetTest.retainAllStringBooleanTest1" configurationId="JUnit" />
504 517
     </history-entry>
505
-    <history-entry file="MySetTest_removeAlllIntegerBooleanTest - 2018.11.16 at 10h 10m 41s.xml">
506
-      <configuration name="MySetTest.removeAlllIntegerBooleanTest" configurationId="JUnit" />
518
+    <history-entry file="MySetTest_retainAllStringBooleanTest1 - 2018.11.16 at 12h 50m 24s.xml">
519
+      <configuration name="MySetTest.retainAllStringBooleanTest1" configurationId="JUnit" />
507 520
     </history-entry>
508 521
   </component>
509 522
   <component name="TimeTrackingManager">
510
-    <option name="totallyTimeSpent" value="38599000" />
523
+    <option name="totallyTimeSpent" value="40437000" />
511 524
   </component>
512 525
   <component name="TodoView">
513 526
     <todo-panel id="selected-file">
@@ -519,7 +532,7 @@
519 532
     </todo-panel>
520 533
   </component>
521 534
   <component name="ToolWindowManager">
522
-    <frame x="0" y="23" width="1280" height="709" extended-state="6" />
535
+    <frame x="-309" y="-1057" width="1920" height="1057" extended-state="6" />
523 536
     <editor active="true" />
524 537
     <layout>
525 538
       <window_info content_ui="combo" id="Project" order="0" weight="0.17285945" />
@@ -531,7 +544,7 @@
531 544
       <window_info id="Favorites" order="6" side_tool="true" />
532 545
       <window_info anchor="bottom" id="Message" order="0" />
533 546
       <window_info anchor="bottom" id="Find" order="1" weight="0.32953367" />
534
-      <window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.4983845" visible="true" weight="0.24149108" />
547
+      <window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.4983845" visible="true" weight="0.18134715" />
535 548
       <window_info anchor="bottom" id="Debug" order="3" sideWeight="0.49757674" weight="0.44246355" />
536 549
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
537 550
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -540,7 +553,7 @@
540 553
       <window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.4983845" weight="0.20907618" />
541 554
       <window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.5016155" side_tool="true" weight="0.20907618" />
542 555
       <window_info anchor="bottom" id="Version Control" order="10" show_stripe_button="false" />
543
-      <window_info anchor="bottom" id="Messages" order="11" weight="0.3273906" />
556
+      <window_info anchor="bottom" id="Messages" order="11" weight="0.32642487" />
544 557
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
545 558
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
546 559
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -570,19 +583,10 @@
570 583
     <MESSAGE value="MyArrayList - Complete&#10;MySet - Working&#10;add, get, contains, remove, addAll, clear" />
571 584
     <MESSAGE value="MyArrayList - Complete&#10;MySet - Working&#10;add, get, contains, remove, addAll, clear, iterator" />
572 585
     <MESSAGE value="MyArrayList - Complete&#10;MySet - Working&#10;add, otherAdd get, contains, remove, addAll, clear, iterator" />
573
-    <option name="LAST_COMMIT_MESSAGE" value="MyArrayList - Complete&#10;MySet - Working&#10;add, otherAdd get, contains, remove, addAll, clear, iterator" />
586
+    <MESSAGE value="MyArrayList - Complete&#10;MySet - Working&#10;add, otherAdd get, contains, remove, addAll, clear, iterator, removeAll" />
587
+    <option name="LAST_COMMIT_MESSAGE" value="MyArrayList - Complete&#10;MySet - Working&#10;add, otherAdd get, contains, remove, addAll, clear, iterator, removeAll" />
574 588
   </component>
575 589
   <component name="XDebuggerManager">
576
-    <breakpoint-manager>
577
-      <breakpoints>
578
-        <line-breakpoint enabled="true" type="java-line">
579
-          <url>file://$PROJECT_DIR$/src/test/java/MySetTest.java</url>
580
-          <line>140</line>
581
-          <properties />
582
-          <option name="timeStamp" value="3" />
583
-        </line-breakpoint>
584
-      </breakpoints>
585
-    </breakpoint-manager>
586 590
     <watches-manager>
587 591
       <configuration name="JUnit">
588 592
         <watch expression="newGenericArray[i]" language="JAVA" />
@@ -715,15 +719,35 @@
715 719
     </entry>
716 720
     <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/util/Set.java">
717 721
       <provider selected="true" editor-type-id="text-editor">
718
-        <state relative-caret-position="61">
719
-          <caret line="308" column="65" selection-start-line="308" selection-start-column="56" selection-end-line="308" selection-end-column="65" />
722
+        <state relative-caret-position="238">
723
+          <caret line="272" column="23" selection-start-line="272" selection-start-column="12" selection-end-line="272" selection-end-column="23" />
724
+        </state>
725
+      </provider>
726
+    </entry>
727
+    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
728
+      <provider selected="true" editor-type-id="text-editor">
729
+        <state relative-caret-position="535">
730
+          <caret line="207" column="15" selection-start-line="207" selection-start-column="15" selection-end-line="207" selection-end-column="15" />
731
+          <folding>
732
+            <element signature="imports" expanded="true" />
733
+            <element signature="e#244#245#0" expanded="true" />
734
+            <element signature="e#286#287#0" expanded="true" />
735
+            <element signature="e#310#311#0" expanded="true" />
736
+            <element signature="e#348#349#0" expanded="true" />
737
+            <element signature="e#1104#1105#0" expanded="true" />
738
+            <element signature="e#1169#1170#0" expanded="true" />
739
+            <element signature="e#1222#1223#0" expanded="true" />
740
+            <element signature="e#1280#1281#0" expanded="true" />
741
+            <element signature="e#5057#5058#0" expanded="true" />
742
+            <element signature="e#5085#5086#0" expanded="true" />
743
+          </folding>
720 744
         </state>
721 745
       </provider>
722 746
     </entry>
723 747
     <entry file="file://$PROJECT_DIR$/src/test/java/MySetTest.java">
724 748
       <provider selected="true" editor-type-id="text-editor">
725
-        <state relative-caret-position="304">
726
-          <caret line="278" column="5" lean-forward="true" selection-start-line="278" selection-start-column="5" selection-end-line="278" selection-end-column="5" />
749
+        <state relative-caret-position="459">
750
+          <caret line="157" column="15" selection-start-line="157" selection-start-column="15" selection-end-line="157" selection-end-column="15" />
727 751
           <folding>
728 752
             <element signature="imports" expanded="true" />
729 753
             <element signature="e#1474#1480#0" expanded="true" />
@@ -732,6 +756,7 @@
732 756
             <element signature="e#2583#2591#0" expanded="true" />
733 757
             <element signature="e#2969#2977#0" expanded="true" />
734 758
             <element signature="e#3343#3349#0" expanded="true" />
759
+            <element signature="e#4161#4167#0" expanded="true" />
735 760
             <element signature="e#4305#4313#0" expanded="true" />
736 761
             <element signature="e#4764#4772#0" expanded="true" />
737 762
             <element signature="e#5216#5224#0" expanded="true" />
@@ -739,28 +764,9 @@
739 764
             <element signature="e#6095#6101#0" expanded="true" />
740 765
             <element signature="e#6641#6647#0" expanded="true" />
741 766
             <element signature="e#7059#7065#0" expanded="true" />
742
-          </folding>
743
-        </state>
744
-      </provider>
745
-    </entry>
746
-    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
747
-      <provider selected="true" editor-type-id="text-editor">
748
-        <state relative-caret-position="101">
749
-          <caret line="166" column="18" lean-forward="true" selection-start-line="161" selection-start-column="19" selection-end-line="161" selection-end-column="28" />
750
-          <folding>
751
-            <element signature="imports" expanded="true" />
752
-            <element signature="e#244#245#0" expanded="true" />
753
-            <element signature="e#286#287#0" expanded="true" />
754
-            <element signature="e#310#311#0" expanded="true" />
755
-            <element signature="e#348#349#0" expanded="true" />
756
-            <element signature="e#1104#1105#0" expanded="true" />
757
-            <element signature="e#1169#1170#0" expanded="true" />
758
-            <element signature="e#1222#1223#0" expanded="true" />
759
-            <element signature="e#1280#1281#0" expanded="true" />
760
-            <element signature="e#3063#3064#0" expanded="true" />
761
-            <element signature="e#3091#3092#0" expanded="true" />
762
-            <element signature="e#3153#3154#0" expanded="true" />
763
-            <element signature="e#3181#3182#0" expanded="true" />
767
+            <element signature="e#7536#7544#0" expanded="true" />
768
+            <element signature="e#8053#8061#0" expanded="true" />
769
+            <element signature="e#8540#8548#0" expanded="true" />
764 770
           </folding>
765 771
         </state>
766 772
       </provider>

+ 25
- 5
src/main/java/MySet.java Wyświetl plik

@@ -137,6 +137,8 @@ public class MySet<T> extends MyArrayList implements Set {
137 137
 // change boolean value
138 138
     @Override
139 139
     public boolean addAll(Collection c) {
140
+        boolean returnValue = false;
141
+
140 142
         T[] newGenericSet = Arrays.copyOf(this.genericSet, size());
141 143
 
142 144
         int i = size();
@@ -145,11 +147,13 @@ public class MySet<T> extends MyArrayList implements Set {
145 147
                 newGenericSet = Arrays.copyOf(genericSet, genericSet.length + 1);
146 148
                 newGenericSet[i] = (T)elem;
147 149
                 genericSet = newGenericSet;
150
+
148 151
                 i++;
152
+                returnValue = true;
149 153
             }
150 154
         }
151 155
         genericSet = newGenericSet;
152
-        return false;
156
+        return returnValue;
153 157
     }
154 158
 
155 159
     @Override
@@ -157,7 +161,7 @@ public class MySet<T> extends MyArrayList implements Set {
157 161
         T[] newGenericSet = null;
158 162
         genericSet = newGenericSet;
159 163
     }
160
-///
164
+
161 165
     @Override
162 166
     public boolean removeAll(Collection c) {
163 167
         boolean returnValue = false;
@@ -177,15 +181,31 @@ public class MySet<T> extends MyArrayList implements Set {
177 181
         genericSet = newGenericSet;
178 182
         return returnValue;
179 183
     }
180
-///
184
+
181 185
     @Override
182 186
     public boolean retainAll(Collection c) {
183
-        return false;
187
+
188
+        boolean returnValue = false;
189
+
190
+        T[] newGenericSet = (T[]) Array.newInstance(this.genericSet.getClass().getComponentType(), 0);
191
+
192
+        int i = 0;
193
+        for (Object elem: genericSet) {
194
+            if (c.contains(elem)){
195
+                newGenericSet = Arrays.copyOf(newGenericSet, newGenericSet.length + 1);
196
+                newGenericSet[i] = (T)elem;
197
+
198
+                returnValue = true;
199
+                i++;
200
+            }
201
+        }
202
+        genericSet = newGenericSet;
203
+        return returnValue;
184 204
     }
185 205
 
186 206
     @Override
187 207
     public boolean containsAll(Collection c) {
188
-        return false;
208
+        return this.addAll(c);
189 209
     }
190 210
 
191 211
 

+ 68
- 0
src/test/java/MySetTest.java Wyświetl plik

@@ -146,6 +146,23 @@ public class MySetTest {
146 146
     }
147 147
 
148 148
     @Test
149
+    public void containsAllLongBooleanTest() {
150
+        // Given
151
+        boolean expected = true;
152
+        Long[] inputArray = {1L, 2L, 3L, 4L};
153
+        ArrayList<Long> addAllArray = new ArrayList<>();
154
+        addAllArray.add(5L); addAllArray.add(6L); addAllArray.add(7L);  addAllArray.add(1L); addAllArray.add(7L);
155
+
156
+        MySet<Long> mySet = new MySet<Long>(inputArray);
157
+
158
+        // When
159
+        boolean actual = mySet.containsAll(addAllArray);
160
+
161
+        // Then
162
+        Assert.assertEquals(expected, actual);
163
+    }
164
+
165
+    @Test
149 166
     public void clearLongTest() {
150 167
         // Given
151 168
         Long[] inputArray = {1L, 2L, 3L, 4L};
@@ -277,4 +294,55 @@ public class MySetTest {
277 294
         // Then
278 295
         Assert.assertEquals(expected, actual);
279 296
     }
297
+    @Test
298
+    public void retainAllStringTest() {
299
+        // Given
300
+        String[] expected = {"a", "4"};
301
+        String[] inputArray = {"a", "2", "3", "4"};
302
+        ArrayList<String> retainAllArray = new ArrayList<>();
303
+        retainAllArray.add("4"); retainAllArray.add("a");
304
+
305
+        MySet<String> mySet = new MySet<String>(inputArray);
306
+
307
+        // When
308
+        mySet.retainAll(retainAllArray);
309
+        String[] actual = mySet.get();
310
+
311
+        // Then
312
+        Assert.assertEquals(expected, actual);
313
+    }
314
+
315
+    @Test
316
+    public void retainAllStringBooleanTest() {
317
+        // Given
318
+        boolean expected = true;
319
+        String[] inputArray = {"a", "2", "3", "4"};
320
+        ArrayList<String> retainAllArray = new ArrayList<>();
321
+        retainAllArray.add("4"); retainAllArray.add("a");
322
+
323
+        MySet<String> mySet = new MySet<String>(inputArray);
324
+
325
+        // When
326
+        boolean actual = mySet.retainAll(retainAllArray);
327
+
328
+        // Then
329
+        Assert.assertEquals(expected, actual);
330
+    }
331
+
332
+    @Test
333
+    public void retainAllStringBooleanTest1() {
334
+        // Given
335
+        boolean expected = false;
336
+        String[] inputArray = {"a", "2", "3", "4"};
337
+        ArrayList<String> retainAllArray = new ArrayList<>();
338
+        retainAllArray.add("5"); retainAllArray.add("b");
339
+
340
+        MySet<String> mySet = new MySet<String>(inputArray);
341
+
342
+        // When
343
+        boolean actual = mySet.retainAll(retainAllArray);
344
+
345
+        // Then
346
+        Assert.assertEquals(expected, actual);
347
+    }
280 348
 }