mirai-core / net.mamoe.mirai.utils / LockFreeLinkedList

LockFreeLinkedList

@PlannedRemoval("1.0.0") open class LockFreeLinkedList<E>

Implementation of lock-free LinkedList.

Modifying can be performed concurrently. Iterating concurrency is guaranteed.

Constructors

<init>

Implementation of lock-free LinkedList.

LockFreeLinkedList()

Properties

size

动态计算的大小

val size: Int

Functions

addAll

先把元素建立好链表, 再加入到 list.

open fun addAll(iterable: Iterable<E>): Unit
open fun addAll(iterable: Sequence<E>): Unit

addLast

open fun addLast(element: E): Unit

clear

open fun clear(onEach: ((E) -> Unit)? = null): Unit

contains

open operator fun contains(element: E): Boolean

containsAll

open fun containsAll(elements: Collection<E>): Boolean

filteringGetOrAdd

过滤并获取, 获取不到则添加一个元素.

fun filteringGetOrAdd(filter: (E) -> Boolean, supplier: () -> E): E

forEach

fun forEach(block: (E) -> Unit): Unit

forEachNode

fun forEachNode(block: (LockFreeLinkedListNode<E>) -> Unit): Unit

isEmpty

open fun isEmpty(): Boolean

peekFirst

open fun peekFirst(): E

plusAssign

open operator fun plusAssign(element: E): Unit

remove

open fun remove(element: E): Boolean

removeAll

open fun removeAll(elements: Collection<E>): Boolean

removeFirst

open fun removeFirst(): E

removeIf

fun removeIf(filter: (E) -> Boolean): Unit

removeLast

open fun removeLast(): E

toString

open fun toString(): String

Extension Functions

asSequence

Builds a Sequence containing all the elements in this in the same order.

fun <E> LockFreeLinkedList<E>.asSequence(): Sequence<E>

filteringGetOrNull

fun <C : Contact> LockFreeLinkedList<C>.filteringGetOrNull(filter: (C) -> Boolean): C?

firstOrNull

fun <C : Contact> LockFreeLinkedList<C>.firstOrNull(filter: (C) -> Boolean): C?

get

operator fun <C : Contact> LockFreeLinkedList<C>.get(id: Long): C

getOrNull

fun <C : Contact> LockFreeLinkedList<C>.getOrNull(id: Long): C?

iterator

operator fun <E> LockFreeLinkedList<E>.iterator(): Iterator<E>

toList

Collect all the elements into a MutableList then cast it as a List

fun <E> LockFreeLinkedList<E>.toList(): List<E>

toMutableList

Collect all the elements into a MutableList.

fun <E> LockFreeLinkedList<E>.toMutableList(): MutableList<E>

toMutableSet

Collect all the elements into a MutableSet.

fun <E> LockFreeLinkedList<E>.toMutableSet(): MutableSet<E>

toSet

Collect all the elements into a MutableSet then cast it as a Set

fun <E> LockFreeLinkedList<E>.toSet(): Set<E>