mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 20:49:54 +08:00
Update docs
This commit is contained in:
parent
8abbfbe4c5
commit
179746c5f7
@ -12,11 +12,12 @@
|
|||||||
package net.mamoe.mirai.contact
|
package net.mamoe.mirai.contact
|
||||||
|
|
||||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||||
|
import net.mamoe.mirai.utils.PlannedRemoval
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue
|
import java.util.concurrent.ConcurrentLinkedQueue
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 只读联系人列表, 无锁链表实现
|
* 只读联系人列表. 元素列表仍可能会被 mirai 内部修改.
|
||||||
*
|
*
|
||||||
* @see ContactList.asSequence
|
* @see ContactList.asSequence
|
||||||
*/
|
*/
|
||||||
@ -27,9 +28,24 @@ internal constructor(@JvmField @MiraiInternalApi public val delegate: Concurrent
|
|||||||
internal constructor(collection: Collection<C>) : this(ConcurrentLinkedQueue(collection))
|
internal constructor(collection: Collection<C>) : this(ConcurrentLinkedQueue(collection))
|
||||||
internal constructor() : this(ConcurrentLinkedQueue())
|
internal constructor() : this(ConcurrentLinkedQueue())
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个 [Contact.id] 为 [id] 的元素. 在不存在时返回 `null`.
|
||||||
|
*/
|
||||||
public operator fun get(id: Long): C? = delegate.firstOrNull { it.id == id }
|
public operator fun get(id: Long): C? = delegate.firstOrNull { it.id == id }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个 [Contact.id] 为 [id] 的元素. 在不存在时抛出 [NoSuchElementException].
|
||||||
|
*/
|
||||||
public fun getOrFail(id: Long): C = get(id) ?: throw NoSuchElementException("Contact $id not found.")
|
public fun getOrFail(id: Long): C = get(id) ?: throw NoSuchElementException("Contact $id not found.")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除 [Contact.id] 为 [id] 的元素.
|
||||||
|
*/
|
||||||
public fun remove(id: Long): Boolean = delegate.removeAll { it.id == id }
|
public fun remove(id: Long): Boolean = delegate.removeAll { it.id == id }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当存在 [Contact.id] 为 [id] 的元素时返回 `true`.
|
||||||
|
*/
|
||||||
public operator fun contains(id: Long): Boolean = get(id) != null
|
public operator fun contains(id: Long): Boolean = get(id) != null
|
||||||
|
|
||||||
override fun toString(): String = delegate.joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
override fun toString(): String = delegate.joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
||||||
|
@ -68,7 +68,7 @@ import kotlin.internal.LowPriorityInOverloadResolution
|
|||||||
*
|
*
|
||||||
* @see Contact.sendMessage 发送消息
|
* @see Contact.sendMessage 发送消息
|
||||||
*/
|
*/
|
||||||
public interface Message { // must be interface. Don't consider any changes.
|
public interface Message {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将 `this` 和 [tail] 连接.
|
* 将 `this` 和 [tail] 连接.
|
||||||
|
Loading…
Reference in New Issue
Block a user