Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
f5261b25
Commit
f5261b25
authored
Jan 06, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make member functions in LockFreeLinkedList open
parent
ce6da7d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
...onMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
+13
-13
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
View file @
f5261b25
...
...
@@ -45,7 +45,7 @@ open class LockFreeLinkedList<E> {
@PublishedApi
internal
val
head
:
Head
<
E
>
=
Head
(
tail
)
fun
removeFirst
():
E
{
open
fun
removeFirst
():
E
{
while
(
true
)
{
val
currentFirst
=
head
.
nextNode
if
(!
currentFirst
.
isValidElementNode
())
{
...
...
@@ -57,11 +57,11 @@ open class LockFreeLinkedList<E> {
}
}
fun
peekFirst
():
E
=
head
.
nextNode
.
letValueIfValid
{
return
it
}
?:
throw
NoSuchElementException
()
open
fun
peekFirst
():
E
=
head
.
nextNode
.
letValueIfValid
{
return
it
}
?:
throw
NoSuchElementException
()
fun
peekLast
():
E
=
head
.
iterateBeforeFirst
{
it
===
tail
}.
letValueIfValid
{
return
it
}
?:
throw
NoSuchElementException
()
open
fun
peekLast
():
E
=
head
.
iterateBeforeFirst
{
it
===
tail
}.
letValueIfValid
{
return
it
}
?:
throw
NoSuchElementException
()
fun
removeLast
():
E
{
open
fun
removeLast
():
E
{
while
(
true
)
{
val
beforeLast
=
head
.
iterateBeforeFirst
{
it
.
nextNode
===
tail
}
if
(!
beforeLast
.
isValidElementNode
())
{
...
...
@@ -74,7 +74,7 @@ open class LockFreeLinkedList<E> {
}
}
fun
addLast
(
element
:
E
)
{
open
fun
addLast
(
element
:
E
)
{
val
node
=
element
.
asNode
(
tail
)
while
(
true
)
{
...
...
@@ -85,7 +85,7 @@ open class LockFreeLinkedList<E> {
}
}
operator
fun
plusAssign
(
element
:
E
)
=
this
.
addLast
(
element
)
ope
n
ope
rator
fun
plusAssign
(
element
:
E
)
=
this
.
addLast
(
element
)
inline
fun
filteringGetOrAdd
(
filter
:
(
E
)
->
Boolean
,
noinline
supplier
:
()
->
E
):
E
{
val
node
=
LazyNode
(
tail
,
supplier
)
...
...
@@ -122,7 +122,7 @@ open class LockFreeLinkedList<E> {
},
{
it
!
is
Tail
})
}.
dropLast
(
4
)
fun
remove
(
element
:
E
):
Boolean
{
open
fun
remove
(
element
:
E
):
Boolean
{
while
(
true
)
{
val
before
=
head
.
iterateBeforeNodeValue
(
element
)
val
toRemove
=
before
.
nextNode
...
...
@@ -148,15 +148,15 @@ open class LockFreeLinkedList<E> {
val
size
:
Int
get
()
=
head
.
countChildIterate
<
Node
<
E
>>({
it
.
nextNode
},
{
it
!
is
Tail
})
-
1
// empty head is always included
operator
fun
contains
(
element
:
E
):
Boolean
{
ope
n
ope
rator
fun
contains
(
element
:
E
):
Boolean
{
forEach
{
if
(
it
==
element
)
return
true
}
return
false
}
@Suppress
(
"unused"
)
fun
containsAll
(
elements
:
Collection
<
E
>):
Boolean
=
elements
.
all
{
contains
(
it
)
}
open
fun
containsAll
(
elements
:
Collection
<
E
>):
Boolean
=
elements
.
all
{
contains
(
it
)
}
fun
isEmpty
():
Boolean
=
head
.
allMatching
{
it
.
isValidElementNode
().
not
()
}
open
fun
isEmpty
():
Boolean
=
head
.
allMatching
{
it
.
isValidElementNode
().
not
()
}
inline
fun
forEach
(
block
:
(
E
)
->
Unit
)
{
var
node
:
Node
<
E
>
=
head
...
...
@@ -167,10 +167,10 @@ open class LockFreeLinkedList<E> {
}
}
fun
addAll
(
elements
:
Collection
<
E
>)
=
elements
.
forEach
{
addLast
(
it
)
}
open
fun
addAll
(
elements
:
Collection
<
E
>)
=
elements
.
forEach
{
addLast
(
it
)
}
@Suppress
(
"unused"
)
fun
clear
()
{
open
fun
clear
()
{
val
first
=
head
.
nextNode
head
.
nextNode
=
tail
first
.
childIterateReturnFirstUnsatisfying
({
...
...
@@ -182,7 +182,7 @@ open class LockFreeLinkedList<E> {
}
@Suppress
(
"unused"
)
fun
removeAll
(
elements
:
Collection
<
E
>):
Boolean
=
elements
.
all
{
remove
(
it
)
}
open
fun
removeAll
(
elements
:
Collection
<
E
>):
Boolean
=
elements
.
all
{
remove
(
it
)
}
/*
...
...
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