Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
ConcurrentSortedLinkedList
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
saad.aswad
ConcurrentSortedLinkedList
Commits
d3fa7a5b
Commit
d3fa7a5b
authored
Nov 10, 2025
by
saad.aswad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List length, sorting in Adding implementations.
parent
ce0771ef
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
29 deletions
+54
-29
workspace.xml
.idea/workspace.xml
+28
-16
LockList.java
src/main/java/LockList.java
+2
-0
RWLockList.java
src/main/java/RWLockList.java
+2
-0
SortList.java
src/main/java/SortList.java
+3
-1
SyncList.java
src/main/java/SyncList.java
+2
-0
AddThread.java
src/test/java/AddThread.java
+2
-2
ContainThread.java
src/test/java/ContainThread.java
+2
-2
RemoveThread.java
src/test/java/RemoveThread.java
+2
-2
SyncListTest.java
src/test/java/SyncListTest.java
+11
-6
No files found.
.idea/workspace.xml
View file @
d3fa7a5b
...
@@ -5,13 +5,14 @@
...
@@ -5,13 +5,14 @@
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"3f4b2924-17d7-4794-bacf-d51c4f0be8bb"
name=
"Changes"
comment=
"Concurrent Sorted Linked List Implementations"
>
<list
default=
"true"
id=
"3f4b2924-17d7-4794-bacf-d51c4f0be8bb"
name=
"Changes"
comment=
"Concurrent Sorted Linked List Implementations"
>
<change
afterPath=
"$PROJECT_DIR$/src/test/java/AddThread.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/src/test/java/ContainThread.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/src/test/java/RandomSeq.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/src/test/java/RemoveThread.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/src/test/java/TestThread.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/README.MD"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/README.MD"
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/AddThread.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/test/java/AddThread.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/test/java/ContainThread.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/test/java/ContainThread.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/test/java/RemoveThread.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/test/java/RemoveThread.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/test/java/SyncListTest.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/test/java/SyncListTest.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>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
@@ -27,11 +28,19 @@
...
@@ -27,11 +28,19 @@
</option>
</option>
</component>
</component>
<component
name=
"Git.Settings"
>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_BRANCH_BY_REPOSITORY"
>
<map>
<entry
key=
"$PROJECT_DIR$"
value=
"master"
/>
</map>
</option>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
</component>
</component>
<component
name=
"MarkdownSettingsMigration"
>
<component
name=
"MarkdownSettingsMigration"
>
<option
name=
"stateVersion"
value=
"1"
/>
<option
name=
"stateVersion"
value=
"1"
/>
</component>
</component>
<component
name=
"ProjectColorInfo"
>
<![CDATA[{
"associatedIndex": 2
}]]>
</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"
/>
...
@@ -40,17 +49,20 @@
...
@@ -40,17 +49,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"
>
{
<component
name=
"PropertiesComponent"
>
<![CDATA[{
"
keyToString
"
: {
"keyToString": {
"
ASKED_ADD_EXTERNAL_FILES
"
:
"
true
"
,
"ASKED_ADD_EXTERNAL_FILES": "true",
"
RunOnceActivity.OpenProjectViewOnStart
"
:
"
true
"
,
"JUnit.SyncListTest.testRun.executor": "Run",
"
RunOnceActivity.ShowReadmeOnStart
"
:
"
true
"
,
"RunOnceActivity.OpenProjectViewOnStart": "true",
"
SHARE_PROJECT_CONFIGURATION_FILES
"
:
"
true
"
,
"RunOnceActivity.ShowReadmeOnStart": "true",
"
project.structure.last.edited
"
:
"
Modules
"
,
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"
project.structure.proportion
"
:
"
0.0
"
,
"git-widget-placeholder": "task1",
"
project.structure.side.proportion
"
:
"
0.0
"
"kotlin-language-version-configured": "true",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0"
}
}
}
</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"
/>
...
...
src/main/java/LockList.java
View file @
d3fa7a5b
...
@@ -25,6 +25,7 @@ public class LockList extends SortList {
...
@@ -25,6 +25,7 @@ public class LockList extends SortList {
Entry
newEntry
=
new
Entry
(
obj
);
Entry
newEntry
=
new
Entry
(
obj
);
newEntry
.
next
=
curr
;
newEntry
.
next
=
curr
;
prev
.
next
=
newEntry
;
prev
.
next
=
newEntry
;
this
.
length
++;
return
true
;
return
true
;
}
}
}
finally
{
}
finally
{
...
@@ -44,6 +45,7 @@ public class LockList extends SortList {
...
@@ -44,6 +45,7 @@ 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
--;
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
src/main/java/RWLockList.java
View file @
d3fa7a5b
...
@@ -24,6 +24,7 @@ public class RWLockList extends SortList {
...
@@ -24,6 +24,7 @@ public class RWLockList extends SortList {
Entry
newEntry
=
new
Entry
(
obj
);
Entry
newEntry
=
new
Entry
(
obj
);
newEntry
.
next
=
curr
;
newEntry
.
next
=
curr
;
prev
.
next
=
newEntry
;
prev
.
next
=
newEntry
;
this
.
length
++;
return
true
;
return
true
;
}
}
}
finally
{
}
finally
{
...
@@ -43,6 +44,7 @@ public class RWLockList extends SortList {
...
@@ -43,6 +44,7 @@ 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
--;
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
src/main/java/SortList.java
View file @
d3fa7a5b
public
abstract
class
SortList
{
public
abstract
class
SortList
{
public
Entry
head
;
public
Entry
head
;
public
long
length
;
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
;
}
}
public
abstract
boolean
add
(
Integer
obj
);
public
abstract
boolean
add
(
Integer
obj
);
...
...
src/main/java/SyncList.java
View file @
d3fa7a5b
...
@@ -18,6 +18,7 @@ public class SyncList extends SortList {
...
@@ -18,6 +18,7 @@ public class SyncList extends SortList {
Entry
newEntry
=
new
Entry
(
obj
);
Entry
newEntry
=
new
Entry
(
obj
);
newEntry
.
next
=
curr
;
newEntry
.
next
=
curr
;
prev
.
next
=
newEntry
;
prev
.
next
=
newEntry
;
this
.
length
++;
return
true
;
return
true
;
}
}
}
}
...
@@ -32,6 +33,7 @@ public class SyncList extends SortList {
...
@@ -32,6 +33,7 @@ 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
--;
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
src/test/java/AddThread.java
View file @
d3fa7a5b
...
@@ -5,8 +5,8 @@ public class AddThread extends TestThread implements Runnable {
...
@@ -5,8 +5,8 @@ public class AddThread extends TestThread implements Runnable {
@Override
@Override
public
void
run
()
{
public
void
run
()
{
for
(
int
i
=
0
;
i
<
nums
.
length
;
i
++
)
{
for
(
Integer
num
:
nums
)
{
list
.
add
(
num
s
[
i
]
);
list
.
add
(
num
);
}
}
}
}
}
}
src/test/java/ContainThread.java
View file @
d3fa7a5b
...
@@ -5,8 +5,8 @@ public class ContainThread extends TestThread implements Runnable{
...
@@ -5,8 +5,8 @@ public class ContainThread extends TestThread implements Runnable{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
for
(
int
i
=
0
;
i
<
nums
.
length
;
i
++
)
{
for
(
Integer
num
:
nums
)
{
list
.
contain
(
num
s
[
i
]
);
list
.
contain
(
num
);
}
}
}
}
}
}
src/test/java/RemoveThread.java
View file @
d3fa7a5b
...
@@ -5,8 +5,8 @@ public class RemoveThread extends TestThread implements Runnable{
...
@@ -5,8 +5,8 @@ public class RemoveThread extends TestThread implements Runnable{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
for
(
int
i
=
0
;
i
<
nums
.
length
;
i
++
)
{
for
(
Integer
num
:
nums
)
{
list
.
remove
(
num
s
[
i
]
);
list
.
remove
(
num
);
}
}
}
}
}
}
\ No newline at end of file
src/test/java/SyncListTest.java
View file @
d3fa7a5b
...
@@ -27,7 +27,7 @@ public class SyncListTest extends TestCase {
...
@@ -27,7 +27,7 @@ public class SyncListTest extends TestCase {
}
}
int
randLen
=
20_000
;
int
randLen
=
20_000
;
public
void
testHelp
(
SortList
list
,
String
label
)
{
public
void
helper
(
SortList
list
,
String
label
)
{
RandomSeq
seq
=
new
RandomSeq
(
0
,
80_000
);
RandomSeq
seq
=
new
RandomSeq
(
0
,
80_000
);
List
<
Thread
>
addThreads
=
new
ArrayList
<>();
List
<
Thread
>
addThreads
=
new
ArrayList
<>();
List
<
Thread
>
containThreads
=
new
ArrayList
<>();
List
<
Thread
>
containThreads
=
new
ArrayList
<>();
...
@@ -58,6 +58,11 @@ public class SyncListTest extends TestCase {
...
@@ -58,6 +58,11 @@ public class SyncListTest extends TestCase {
System
.
out
.
println
(
"ADD "
+
label
+
" execution task: "
+
endA
+
" ms"
);
System
.
out
.
println
(
"ADD "
+
label
+
" execution task: "
+
endA
+
" ms"
);
long
listLengthAfterAdds
=
list
.
length
;
System
.
out
.
println
(
"Length of the list after adding: "
+
listLengthAfterAdds
);
long
startC
=
System
.
currentTimeMillis
();
long
startC
=
System
.
currentTimeMillis
();
containThreads
.
stream
().
forEach
(
e
->
e
.
start
()
);
containThreads
.
stream
().
forEach
(
e
->
e
.
start
()
);
...
@@ -89,12 +94,12 @@ public class SyncListTest extends TestCase {
...
@@ -89,12 +94,12 @@ public class SyncListTest extends TestCase {
public
void
testRun
(){
public
void
testRun
(){
SyncList
syncList
=
new
SyncList
();
SyncList
syncList
=
new
SyncList
();
testHelp
(
syncList
,
"Synchronization"
);
helper
(
syncList
,
"Synchronization"
);
System
.
out
.
println
(
"=============="
);
System
.
out
.
println
(
"==============
=========================
"
);
RWLockList
rwLockList
=
new
RWLockList
();
RWLockList
rwLockList
=
new
RWLockList
();
testHelp
(
rwLockList
,
"RWLock"
);
helper
(
rwLockList
,
"RWLock"
);
System
.
out
.
println
(
"=============="
);
System
.
out
.
println
(
"==============
=========================
"
);
LockList
list
=
new
LockList
();
LockList
list
=
new
LockList
();
testHelp
(
list
,
"Lock"
);
helper
(
list
,
"Lock"
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment