PriorityQueuePolicy

class PriorityQueuePolicy<T : Any>(initialContents: Collection<T> = emptyList(), comparator: Comparator<T>) : QueuePolicy<T>

Priority queue policy. Entities are dequeued according to a priority order defined by the comparator. Lower priority entities (earlier in the comparator order) are dequeued first.

Parameters

T

the type of entities in the queue

initialContents

the initial entities in the queue

comparator

the Comparator that defines the priority order

Constructors

Link copied to clipboard
constructor(initialContents: Collection<T> = emptyList(), comparator: Comparator<T>)

Properties

Link copied to clipboard
open override val contents: Sequence<T?>

A sequence of all entities currently in the queue, in their stored order.

Functions

Link copied to clipboard
open override fun dequeue(): T

Removes and returns an entity from the queue according to the policy.

Link copied to clipboard
open override fun enqueue(obj: T)

Adds an entity to the queue according to the policy.

Link copied to clipboard
open override fun reportOccupancy(): Int

Reports the current number of entities in the queue.

Link copied to clipboard

Indicates whether this policy supports residence time tracking for entities.