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
a105a483
Commit
a105a483
authored
Feb 04, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve ContactList
parent
bf645717
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
.../commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
+33
-3
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
View file @
a105a483
...
@@ -2,9 +2,7 @@
...
@@ -2,9 +2,7 @@
package
net.mamoe.mirai.contact
package
net.mamoe.mirai.contact
import
net.mamoe.mirai.utils.LockFreeLinkedList
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.joinToString
/**
/**
...
@@ -52,3 +50,35 @@ inline fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) ->
...
@@ -52,3 +50,35 @@ inline fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) ->
return
null
return
null
}
}
/**
* Collect all the elements into a [MutableList] then cast it as a [List]
*/
fun
<
E
:
Contact
>
ContactList
<
E
>.
toList
():
List
<
E
>
=
toMutableList
()
/**
* Collect all the elements into a [MutableList].
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
fun
<
E
:
Contact
>
ContactList
<
E
>.
toMutableList
():
MutableList
<
E
>
=
this
.
delegate
.
toMutableList
()
/**
* Collect all the elements into a [MutableSet] then cast it as a [Set]
*/
fun
<
E
:
Contact
>
ContactList
<
E
>.
toSet
():
Set
<
E
>
=
toMutableSet
()
/**
* Collect all the elements into a [MutableSet].
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
fun
<
E
:
Contact
>
ContactList
<
E
>.
toMutableSet
():
MutableSet
<
E
>
=
this
.
delegate
.
toMutableSet
()
/**
* Builds a [Sequence] containing all the elements in [this] in the same order.
*
* Note that the sequence is dynamic, that is, elements are yielded atomically only when it is required
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
fun
<
E
:
Contact
>
ContactList
<
E
>.
asSequence
():
Sequence
<
E
>
{
return
this
.
delegate
.
asSequence
()
}
\ No newline at end of file
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