LinkedMinimumHeap

Represents a linked minimum heap. See MinimumHeap for general definition of minimum heap.

Linked heap is a heap with structure of a linked list. However, the order of elements in linked structure may be defined in different ways. For example, it may be a chronological order (i.e. new elements are added to the end of the order and reconstruction of the heap won't change the order). Or a list representation order (i.e. the first element is the root node, then its children go next, then their children go next, and so on and reconstruction of the heap will change the order). See implementations' documentations to get the behaviour you need.

Properties

Link copied to clipboard

Reversible iterable that is a view on elements of that heap.

Link copied to clipboard

Linked reified set that is a view on nodes of that heap.

Link copied to clipboard

Reversible iterable that is a view on priorities of that heap.

Link copied to clipboard
abstract val size: UInt

Number of elements in the collection.

Functions

Link copied to clipboard
abstract override fun add(element: Element, priority: Priority): LinkedHeapNode<Element, Priority>

Adds the element with corresponding priority to the heap and returns constructed node that corresponds to the element and the priority.

Link copied to clipboard
abstract operator override fun equals(other: Any?): Boolean

Legacy equality operation. Must return the result of referential equality.

Link copied to clipboard
abstract override fun hashCode(): Int

Legacy hash computation operation. Must return any Int value.

Link copied to clipboard

Checks if the heap is empty.

Link copied to clipboard

Checks if the heap is not empty.

Link copied to clipboard
abstract override fun popMinimum(): LinkedHeapNode<Element, Priority>

Retrieves the root node and removes it from the heap. It is a node with the minimum priority.

Link copied to clipboard
abstract override fun takeMinimum(): LinkedHeapNode<Element, Priority>

Retrieves the root node. It is a node with the minimum priority.

Link copied to clipboard
abstract override fun toString(): String

Represents the heap as a string. Must return a string in the following form.