CircularDoublyLinkedList

internal class CircularDoublyLinkedList<T> : Queue<T> (source)

Provides a basic implementation of an intrusive circular doubly linked non-thread safe list. Allows for efficient insertion or removal of elements from any position in the list, as the nodes are not stored contiguously in memory (unlike an array).

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
private class NodeImpl<T>(val maybeValue: T?) : Node<T>

Properties

Link copied to clipboard

Checks if the list is empty.

Link copied to clipboard
Link copied to clipboard
val headNode: Node<T>?

If the list is not empty, returns the head node otherwise returns null.

Link copied to clipboard
val headValue: T?

If the list is not empty, returns the value of the head node otherwise returns null.

Link copied to clipboard

Checks if the list is not empty.

Link copied to clipboard
open override var size: Int

Returns the number of elements in the queue.

Functions

Link copied to clipboard
open suspend override fun dequeue(): Node<T>

Dequeues the head element from the queue.

Link copied to clipboard
open suspend override fun enqueue(value: T): Node<T>

Enqueues a new element into the queue.

Link copied to clipboard
open suspend override fun headCondition(cond: (T) -> Boolean): Boolean

Checks if the given condition on the head element of the queue is satisfied.

Link copied to clipboard
fun isHeadNode(node: Node<T>): Boolean

Checks if the given node is the head node.

Link copied to clipboard
open suspend override fun remove(node: Node<T>)

Removes a specific node from the queue.