Commit 0d6fe042 authored by saad.aswad's avatar saad.aswad

List length, sorting in Adding implementations.

parent 397a487e
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
<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/LockList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/LockList.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/RWLockList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/RWLockList.java" 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/main/java/SyncList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/SyncList.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" />
...@@ -20,7 +27,7 @@ ...@@ -20,7 +27,7 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="master" /> <entry key="$PROJECT_DIR$" value="task1" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
...@@ -46,7 +53,7 @@ ...@@ -46,7 +53,7 @@
"RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true", "SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "master", "git-widget-placeholder": "task2",
"kotlin-language-version-configured": "true", "kotlin-language-version-configured": "true",
"project.structure.last.edited": "Modules", "project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0", "project.structure.proportion": "0.0",
......
...@@ -46,8 +46,10 @@ public class LockList extends SortList { ...@@ -46,8 +46,10 @@ public class LockList extends SortList {
if (curr.object.equals(obj)) { if (curr.object.equals(obj)) {
prev.next = curr.next; prev.next = curr.next;
this.length--; this.length--;
removeSuccess++;
return true; return true;
} else { } else {
removeFailure++;
return false; return false;
} }
} finally { } finally {
...@@ -67,8 +69,10 @@ public class LockList extends SortList { ...@@ -67,8 +69,10 @@ public class LockList extends SortList {
curr = prev.next; curr = prev.next;
} }
if (curr.object.equals(obj) || prev.object.equals(obj)) { if (curr.object.equals(obj) || prev.object.equals(obj)) {
conatinSuccess++;
return true; return true;
} else { } else {
conatinFailure++;
return false; return false;
} }
} finally { } finally {
......
...@@ -45,8 +45,10 @@ public class RWLockList extends SortList { ...@@ -45,8 +45,10 @@ public class RWLockList extends SortList {
if (curr.object.equals(obj)) { if (curr.object.equals(obj)) {
prev.next = curr.next; prev.next = curr.next;
this.length--; this.length--;
removeSuccess++;
return true; return true;
} else { } else {
removeFailure++;
return false; return false;
} }
} finally { } finally {
...@@ -66,8 +68,10 @@ public class RWLockList extends SortList { ...@@ -66,8 +68,10 @@ public class RWLockList extends SortList {
curr = prev.next; curr = prev.next;
} }
if (curr.object.equals(obj) || prev.object.equals(obj)) { if (curr.object.equals(obj) || prev.object.equals(obj)) {
conatinSuccess++;
return true; return true;
} else { } else {
conatinFailure++;
return false; return false;
} }
} finally { } finally {
......
...@@ -3,10 +3,15 @@ public abstract class SortList { ...@@ -3,10 +3,15 @@ public abstract class SortList {
public Entry head; public Entry head;
public long length; public long length;
public long conatinSuccess = 0;
public long conatinFailure = 0;
public long removeSuccess = 0;
public long removeFailure = 0;
public SortList() { public SortList() {
this.head = new Entry(Integer.MIN_VALUE); this.head = new Entry(Integer.MIN_VALUE);
this.head.next =new Entry(Integer.MAX_VALUE); this.head.next =new Entry(Integer.MAX_VALUE);
this.length = 2; this.length = 0;
} }
public abstract boolean add(Integer obj); public abstract boolean add(Integer obj);
...@@ -21,4 +26,7 @@ public abstract class SortList { ...@@ -21,4 +26,7 @@ public abstract class SortList {
} }
} }
} }
...@@ -34,8 +34,10 @@ public class SyncList extends SortList { ...@@ -34,8 +34,10 @@ public class SyncList extends SortList {
if (curr.object.equals(obj)) { if (curr.object.equals(obj)) {
prev.next = curr.next; prev.next = curr.next;
this.length--; this.length--;
removeSuccess++;
return true; return true;
} else { } else {
removeFailure++;
return false; return false;
} }
...@@ -50,8 +52,10 @@ public class SyncList extends SortList { ...@@ -50,8 +52,10 @@ public class SyncList extends SortList {
curr = prev.next; curr = prev.next;
} }
if (curr.object.equals(obj) || prev.object.equals(obj)) { if (curr.object.equals(obj) || prev.object.equals(obj)) {
conatinSuccess++;
return true; return true;
} else { } else {
conatinFailure++;
return false; return false;
} }
} }
......
...@@ -74,7 +74,11 @@ public class SyncListTest extends TestCase { ...@@ -74,7 +74,11 @@ public class SyncListTest extends TestCase {
} }
}); });
long endC = System.currentTimeMillis() - startC; long endC = System.currentTimeMillis() - startC;
System.out.println("Contain "+label+" execution task: "+endC+" ms"); System.out.println("\nContain "+label+" execution task: "+endC+" ms");
System.out.println("Counter of Success contain operations: "+list.conatinSuccess);
System.out.println("Counter of Failure contain operations: "+list.conatinFailure);
long startR = System.currentTimeMillis(); long startR = System.currentTimeMillis();
...@@ -89,16 +93,16 @@ public class SyncListTest extends TestCase { ...@@ -89,16 +93,16 @@ public class SyncListTest extends TestCase {
long endR = System.currentTimeMillis() - startR; long endR = System.currentTimeMillis() - startR;
System.out.println("Remove "+label+" execution task: "+endR+" ms"); System.out.println("\nRemove "+label+" execution task: "+endR+" ms");
} }
public void testRun(){ public void testRun(){
SyncList syncList = new SyncList(); SyncList syncList = new SyncList();
helper(syncList,"Synchronization"); helper(syncList,"Synchronization");
System.out.println("======================================="); System.out.println("=======================================\n");
RWLockList rwLockList = new RWLockList(); RWLockList rwLockList = new RWLockList();
helper(rwLockList, "RWLock"); helper(rwLockList, "RWLock");
System.out.println("======================================="); System.out.println("=======================================\n");
LockList list = new LockList(); LockList list = new LockList();
helper(list,"Lock"); helper(list,"Lock");
} }
......
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