NedRedmond před 6 roky
rodič
revize
27f143620c

+ 43
- 59
.idea/workspace.xml Zobrazit soubor

@@ -2,13 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="4cada9f2-6d0f-46eb-ad0f-05b3102352a5" name="Default Changelist" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
9 5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/singlylinkedlist/MainApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/singlylinkedlist/MainApplication.java" afterDir="false" />
12 6
       <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedList.java" afterDir="false" />
13 7
       <change beforePath="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedListTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedListTest.java" afterDir="false" />
14 8
     </list>
@@ -23,12 +17,12 @@
23 17
     <session id="-472648142">
24 18
       <usages-collector id="statistics.lifecycle.project">
25 19
         <counts>
26
-          <entry key="project.closed" value="4" />
20
+          <entry key="project.closed" value="6" />
27 21
           <entry key="project.open.time.0" value="1" />
28
-          <entry key="project.open.time.1" value="2" />
22
+          <entry key="project.open.time.1" value="4" />
29 23
           <entry key="project.open.time.12" value="1" />
30 24
           <entry key="project.open.time.6" value="1" />
31
-          <entry key="project.opened" value="5" />
25
+          <entry key="project.opened" value="7" />
32 26
         </counts>
33 27
       </usages-collector>
34 28
       <usages-collector id="statistics.file.extensions.open">
@@ -43,18 +37,18 @@
43 37
       </usages-collector>
44 38
       <usages-collector id="statistics.file.extensions.edit">
45 39
         <counts>
46
-          <entry key="java" value="3825" />
40
+          <entry key="java" value="4009" />
47 41
         </counts>
48 42
       </usages-collector>
49 43
       <usages-collector id="statistics.file.types.edit">
50 44
         <counts>
51
-          <entry key="JAVA" value="3825" />
45
+          <entry key="JAVA" value="4009" />
52 46
         </counts>
53 47
       </usages-collector>
54 48
     </session>
55 49
   </component>
56 50
   <component name="FileEditorManager">
57
-    <splitter split-orientation="horizontal" split-proportion="0.43593314">
51
+    <splitter split-orientation="horizontal" split-proportion="0.45851216">
58 52
       <split-first>
59 53
         <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
60 54
           <file pinned="false" current-in-tab="false">
@@ -69,14 +63,8 @@
69 63
           <file pinned="false" current-in-tab="true">
70 64
             <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedList.java">
71 65
               <provider selected="true" editor-type-id="text-editor">
72
-                <state relative-caret-position="2235">
73
-                  <caret line="149" selection-start-line="149" selection-end-line="149" />
74
-                  <folding>
75
-                    <element signature="e#3864#3865#0" expanded="true" />
76
-                    <element signature="e#3896#3897#0" expanded="true" />
77
-                    <element signature="e#4115#4116#0" expanded="true" />
78
-                    <element signature="e#4155#4156#0" expanded="true" />
79
-                  </folding>
66
+                <state relative-caret-position="245">
67
+                  <caret line="124" column="29" lean-forward="true" selection-start-line="124" selection-start-column="29" selection-end-line="124" selection-end-column="35" />
80 68
                 </state>
81 69
               </provider>
82 70
             </entry>
@@ -93,8 +81,8 @@
93 81
           <file pinned="false" current-in-tab="false">
94 82
             <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedListTest.java">
95 83
               <provider selected="true" editor-type-id="text-editor">
96
-                <state relative-caret-position="165">
97
-                  <caret line="13" column="8" selection-start-line="13" selection-start-column="8" selection-end-line="13" selection-end-column="8" />
84
+                <state relative-caret-position="180">
85
+                  <caret line="12" column="8" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" />
98 86
                   <folding>
99 87
                     <element signature="imports" expanded="true" />
100 88
                   </folding>
@@ -109,8 +97,8 @@
109 97
           <file pinned="false" current-in-tab="true">
110 98
             <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedListTest.java">
111 99
               <provider selected="true" editor-type-id="text-editor">
112
-                <state relative-caret-position="299">
113
-                  <caret line="21" column="22" selection-start-line="21" selection-start-column="22" selection-end-line="21" selection-end-column="22" />
100
+                <state relative-caret-position="269">
101
+                  <caret line="193" column="9" lean-forward="true" selection-start-line="193" selection-start-column="9" selection-end-line="193" selection-end-column="9" />
114 102
                   <folding>
115 103
                     <element signature="imports" expanded="true" />
116 104
                   </folding>
@@ -121,7 +109,7 @@
121 109
           <file pinned="false" current-in-tab="false">
122 110
             <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/lang/Comparable.java">
123 111
               <provider selected="true" editor-type-id="text-editor">
124
-                <state relative-caret-position="-216">
112
+                <state relative-caret-position="1080">
125 113
                   <caret line="95" column="17" selection-start-line="95" selection-start-column="17" selection-end-line="95" selection-end-column="17" />
126 114
                 </state>
127 115
               </provider>
@@ -231,7 +219,7 @@
231 219
   <component name="PropertiesComponent">
232 220
     <property name="WebServerToolWindowFactoryState" value="false" />
233 221
     <property name="aspect.path.notification.shown" value="true" />
234
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541259452760" />
222
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541262400955" />
235 223
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
236 224
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
237 225
   </component>
@@ -247,7 +235,7 @@
247 235
       </list>
248 236
     </option>
249 237
   </component>
250
-  <component name="RunManager" selected="JUnit.SinglyLinkedListTest">
238
+  <component name="RunManager" selected="JUnit.SinglyLinkedListTest.SinglyLinkedListTest11">
251 239
     <configuration name="SinglyLinkedListTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
252 240
       <module name="singlylinkedlist" />
253 241
       <extension name="coverage">
@@ -335,9 +323,9 @@
335 323
     </list>
336 324
     <recent_temporary>
337 325
       <list>
326
+        <item itemvalue="JUnit.SinglyLinkedListTest.SinglyLinkedListTest11" />
338 327
         <item itemvalue="JUnit.SinglyLinkedListTest" />
339 328
         <item itemvalue="JUnit.SinglyLinkedListTest.SinglyLinkedListTest12" />
340
-        <item itemvalue="JUnit.SinglyLinkedListTest.SinglyLinkedListTest11" />
341 329
         <item itemvalue="JUnit.SinglyLinkedListTest.SinglyLinkedListTest10" />
342 330
         <item itemvalue="JUnit.SinglyLinkedListTest.SinglyLinkedListTest9" />
343 331
       </list>
@@ -357,29 +345,13 @@
357 345
       <workItem from="1541027519485" duration="36000" />
358 346
       <workItem from="1541092107678" duration="2198000" />
359 347
       <workItem from="1541196317502" duration="5339000" />
360
-      <workItem from="1541234299179" duration="5970000" />
348
+      <workItem from="1541234299179" duration="6045000" />
349
+      <workItem from="1541259898121" duration="48000" />
350
+      <workItem from="1541261768122" duration="1211000" />
361 351
     </task>
362 352
     <servers />
363 353
   </component>
364 354
   <component name="TestHistory">
365
-    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest12 - 2018.11.03 at 11h 14m 18s.xml">
366
-      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest12" configurationId="JUnit" />
367
-    </history-entry>
368
-    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest12 - 2018.11.03 at 11h 18m 27s.xml">
369
-      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest12" configurationId="JUnit" />
370
-    </history-entry>
371
-    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest12 - 2018.11.03 at 11h 19m 59s.xml">
372
-      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest12" configurationId="JUnit" />
373
-    </history-entry>
374
-    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest12 - 2018.11.03 at 11h 20m 43s.xml">
375
-      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest12" configurationId="JUnit" />
376
-    </history-entry>
377
-    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest12 - 2018.11.03 at 11h 20m 55s.xml">
378
-      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest12" configurationId="JUnit" />
379
-    </history-entry>
380
-    <history-entry file="SinglyLinkedListTest - 2018.11.03 at 11h 28m 21s.xml">
381
-      <configuration name="SinglyLinkedListTest" configurationId="JUnit" />
382
-    </history-entry>
383 355
     <history-entry file="SinglyLinkedListTest - 2018.11.03 at 11h 28m 39s.xml">
384 356
       <configuration name="SinglyLinkedListTest" configurationId="JUnit" />
385 357
     </history-entry>
@@ -392,9 +364,27 @@
392 364
     <history-entry file="SinglyLinkedListTest - 2018.11.03 at 11h 29m 51s.xml">
393 365
       <configuration name="SinglyLinkedListTest" configurationId="JUnit" />
394 366
     </history-entry>
367
+    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest11 - 2018.11.03 at 12h 21m 35s.xml">
368
+      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest11" configurationId="JUnit" />
369
+    </history-entry>
370
+    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest11 - 2018.11.03 at 12h 23m 01s.xml">
371
+      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest11" configurationId="JUnit" />
372
+    </history-entry>
373
+    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest11 - 2018.11.03 at 12h 23m 30s.xml">
374
+      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest11" configurationId="JUnit" />
375
+    </history-entry>
376
+    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest11 - 2018.11.03 at 12h 24m 06s.xml">
377
+      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest11" configurationId="JUnit" />
378
+    </history-entry>
379
+    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest11 - 2018.11.03 at 12h 24m 28s.xml">
380
+      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest11" configurationId="JUnit" />
381
+    </history-entry>
382
+    <history-entry file="SinglyLinkedListTest_SinglyLinkedListTest11 - 2018.11.03 at 12h 24m 56s.xml">
383
+      <configuration name="SinglyLinkedListTest.SinglyLinkedListTest11" configurationId="JUnit" />
384
+    </history-entry>
395 385
   </component>
396 386
   <component name="TimeTrackingManager">
397
-    <option name="totallyTimeSpent" value="15139000" />
387
+    <option name="totallyTimeSpent" value="16473000" />
398 388
   </component>
399 389
   <component name="ToolWindowManager">
400 390
     <frame x="0" y="0" width="1440" height="900" extended-state="6" />
@@ -454,28 +444,22 @@
454 444
     </entry>
455 445
     <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/src.zip!/java/lang/Comparable.java">
456 446
       <provider selected="true" editor-type-id="text-editor">
457
-        <state relative-caret-position="-216">
447
+        <state relative-caret-position="1080">
458 448
           <caret line="95" column="17" selection-start-line="95" selection-start-column="17" selection-end-line="95" selection-end-column="17" />
459 449
         </state>
460 450
       </provider>
461 451
     </entry>
462 452
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedList.java">
463 453
       <provider selected="true" editor-type-id="text-editor">
464
-        <state relative-caret-position="2235">
465
-          <caret line="149" selection-start-line="149" selection-end-line="149" />
466
-          <folding>
467
-            <element signature="e#3864#3865#0" expanded="true" />
468
-            <element signature="e#3896#3897#0" expanded="true" />
469
-            <element signature="e#4115#4116#0" expanded="true" />
470
-            <element signature="e#4155#4156#0" expanded="true" />
471
-          </folding>
454
+        <state relative-caret-position="245">
455
+          <caret line="124" column="29" lean-forward="true" selection-start-line="124" selection-start-column="29" selection-end-line="124" selection-end-column="35" />
472 456
         </state>
473 457
       </provider>
474 458
     </entry>
475 459
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedListTest.java">
476 460
       <provider selected="true" editor-type-id="text-editor">
477
-        <state relative-caret-position="299">
478
-          <caret line="21" column="22" selection-start-line="21" selection-start-column="22" selection-end-line="21" selection-end-column="22" />
461
+        <state relative-caret-position="269">
462
+          <caret line="193" column="9" lean-forward="true" selection-start-line="193" selection-start-column="9" selection-end-line="193" selection-end-column="9" />
479 463
           <folding>
480 464
             <element signature="imports" expanded="true" />
481 465
           </folding>

+ 13
- 4
src/main/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedList.java Zobrazit soubor

@@ -117,10 +117,19 @@ public class SinglyLinkedList<T extends Comparable<T>> {
117 117
         return false;
118 118
     }
119 119
 
120
-    public SinglyLinkedList<T> copy(SinglyLinkedList<T> original) {
121
-        SinglyLinkedList<T> copyOfOriginal = new SinglyLinkedList<T>();
122
-        copyOfOriginal = original;
123
-        return copyOfOriginal;
120
+    public SinglyLinkedList<T> copy() {
121
+        SinglyLinkedList<T> copy = new SinglyLinkedList<T>();
122
+
123
+        Node node = head;
124
+
125
+        for (int i = 1; i <= size() && node.getNext() != null; i++) {
126
+            copy.add(node.getData());
127
+            node = node.getNext();
128
+        }
129
+
130
+        copy.add(tail.getData());
131
+
132
+        return copy;
124 133
     }
125 134
 
126 135
     public void sort() {

+ 15
- 3
src/test/java/com/zipcodewilmington/singlylinkedlist/SinglyLinkedListTest.java Zobrazit soubor

@@ -1,7 +1,6 @@
1 1
 package com.zipcodewilmington.singlylinkedlist;
2 2
 
3 3
 import org.junit.Assert;
4
-import org.junit.Before;
5 4
 import org.junit.Test;
6 5
 
7 6
 /**
@@ -182,9 +181,22 @@ public class SinglyLinkedListTest {
182 181
         linkedList.add("c");
183 182
 
184 183
         SinglyLinkedList actual = linkedList;
185
-        SinglyLinkedList expected = linkedList.copy(linkedList);
184
+        SinglyLinkedList expected = linkedList.copy();
185
+
186
+        for (int i = 1; i <= expected.size(); i++) {
187
+            System.out.println(expected.get(i));
188
+        }
189
+
190
+        expected.remove();
191
+
192
+        for (int i = 1; i <= expected.size(); i++) {
193
+            System.out.println(expected.get(i));
194
+        }
195
+
196
+        for (int i = 1; i < linkedList.size()+1; i++) {
197
+            System.out.println(linkedList.get(i));
198
+        }
186 199
 
187
-        Assert.assertTrue(actual.equals(expected));
188 200
     }
189 201
 
190 202
     @Test