Commit 4346ea02 authored by Him188's avatar Him188

Fix list

parent f60ff21a
...@@ -101,8 +101,9 @@ open class LockFreeLinkedList<E> { ...@@ -101,8 +101,9 @@ open class LockFreeLinkedList<E> {
open fun peekFirst(): E { open fun peekFirst(): E {
return head return head
.iterateBeforeFirst { it === tail } .iterateBeforeFirst { it.isValidElementNode() }
.takeUnless { it.isTail() } .takeUnless { it.isTail() }
?.nextNode
?.nodeValue ?.nodeValue
?: throw NoSuchElementException() ?: throw NoSuchElementException()
} }
...@@ -203,7 +204,7 @@ open class LockFreeLinkedList<E> { ...@@ -203,7 +204,7 @@ open class LockFreeLinkedList<E> {
internal fun <E> LockFreeLinkedListNode<E>.compareAndSetNextNodeRef(expect: LockFreeLinkedListNode<E>, update: LockFreeLinkedListNode<E>) = internal fun <E> LockFreeLinkedListNode<E>.compareAndSetNextNodeRef(expect: LockFreeLinkedListNode<E>, update: LockFreeLinkedListNode<E>) =
this.nextNodeRef.compareAndSet(expect, update) this.nextNodeRef.compareAndSet(expect, update)
override fun toString(): String = asSequence().joinToString() override fun toString(): String = "[" + asSequence().joinToString() + "]"
@Suppress("unused") @Suppress("unused")
internal fun getLinkStructure(): String = buildString { internal fun getLinkStructure(): String = buildString {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment