mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 09:10:11 +08:00
Fix name
This commit is contained in:
parent
220e6d42f5
commit
e8b0c99006
@ -259,16 +259,16 @@ internal class GroupImpl(
|
||||
|
||||
|
||||
override operator fun get(id: Long): Member {
|
||||
return members.delegate.filteringGetOrNull { it.id == id }
|
||||
return members.delegate.firstOrNull { it.id == id }
|
||||
?: throw NoSuchElementException("member $id not found in group $uin")
|
||||
}
|
||||
|
||||
override fun contains(id: Long): Boolean {
|
||||
return members.delegate.filteringGetOrNull { it.id == id } != null
|
||||
return members.delegate.firstOrNull { it.id == id } != null
|
||||
}
|
||||
|
||||
override fun getOrNull(id: Long): Member? {
|
||||
return members.delegate.filteringGetOrNull { it.id == id }
|
||||
return members.delegate.firstOrNull { it.id == id }
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class, LowLevelAPI::class)
|
||||
|
@ -50,7 +50,8 @@ class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedLis
|
||||
return null
|
||||
}
|
||||
|
||||
override fun toString(): String = delegate.asSequence().joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
||||
override fun toString(): String =
|
||||
delegate.asSequence().joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
||||
}
|
||||
|
||||
operator fun <C : Contact> LockFreeLinkedList<C>.get(id: Long): C {
|
||||
@ -63,11 +64,17 @@ fun <C : Contact> LockFreeLinkedList<C>.getOrNull(id: Long): C? {
|
||||
return null
|
||||
}
|
||||
|
||||
inline fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) -> Boolean): C? {
|
||||
inline fun <C : Contact> LockFreeLinkedList<C>.firstOrNull(filter: (C) -> Boolean): C? {
|
||||
forEach { if (filter(it)) return it }
|
||||
return null
|
||||
}
|
||||
|
||||
@PlannedRemoval("1.0.0")
|
||||
@Deprecated("use firstOrNull", replaceWith = ReplaceWith("firstOrNull(filter)"), level = DeprecationLevel.ERROR)
|
||||
inline fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) -> Boolean): C? {
|
||||
return this.firstOrNull(filter)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Collect all the elements into a [MutableList] then cast it as a [List]
|
||||
|
Loading…
Reference in New Issue
Block a user