Commit 7f1f983c authored by saad.aswad's avatar saad.aswad

List length, sorting in Adding implementations.

parent c9239d66
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3f4b2924-17d7-4794-bacf-d51c4f0be8bb" name="Changes" comment="List length, sorting in Adding implementations." /> <list default="true" id="3f4b2924-17d7-4794-bacf-d51c4f0be8bb" name="Changes" comment="List length, sorting in Adding implementations.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/SortList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/SortList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/SyncListTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/SyncListTest.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -28,9 +32,9 @@ ...@@ -28,9 +32,9 @@
<component name="MarkdownSettingsMigration"> <component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" /> <option name="stateVersion" value="1" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo">{
"associatedIndex": 2 &quot;associatedIndex&quot;: 2
}]]></component> }</component>
<component name="ProjectId" id="2NMPKhBDgdyw9qxmyQBX74HdmhD" /> <component name="ProjectId" id="2NMPKhBDgdyw9qxmyQBX74HdmhD" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true"> <component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" /> <ConfirmationsSetting value="2" id="Add" />
...@@ -39,20 +43,20 @@ ...@@ -39,20 +43,20 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"ASKED_ADD_EXTERNAL_FILES": "true", &quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
"JUnit.SyncListTest.testRun.executor": "Run", &quot;JUnit.SyncListTest.testRun.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"git-widget-placeholder": "task1", &quot;git-widget-placeholder&quot;: &quot;task1&quot;,
"kotlin-language-version-configured": "true", &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
"project.structure.last.edited": "Modules", &quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
"project.structure.proportion": "0.0", &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
"project.structure.side.proportion": "0.0" &quot;project.structure.side.proportion&quot;: &quot;0.0&quot;
} }
}]]></component> }</component>
<component name="RunManager" selected="JUnit.SyncListTest.testRun"> <component name="RunManager" selected="JUnit.SyncListTest.testRun">
<configuration name="SyncListTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> <configuration name="SyncListTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="SortLinkedList" /> <module name="SortLinkedList" />
......
...@@ -21,4 +21,17 @@ public abstract class SortList { ...@@ -21,4 +21,17 @@ public abstract class SortList {
} }
} }
public boolean checkSorted() {
Entry current = this.head.next;
while (current.next != null) {
if (current.object.compareTo(current.next.object) > 0) {
return false;
}
current = current.next;
}
return true;
}
} }
...@@ -61,6 +61,9 @@ public class SyncListTest extends TestCase { ...@@ -61,6 +61,9 @@ public class SyncListTest extends TestCase {
long listLengthAfterAdds = list.length; long listLengthAfterAdds = list.length;
System.out.println("Length of the list after adding: "+listLengthAfterAdds); System.out.println("Length of the list after adding: "+listLengthAfterAdds);
String listIsSorted = list.checkSorted() ? "The List is sorted" : "The list is not sorted";
System.out.println(listIsSorted);
long startC = System.currentTimeMillis(); long startC = System.currentTimeMillis();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment