A Queue implemented using a backing Array where the front of the queue is the smallest element according to the order relation defined by compare() function. Note that this implementation doesn't guarantee the back/last element to be the largest element of the queue.

The size of the backing Array is called the capacity of the PriorityQueue. The capacity of a new instance is specified by the given initialCapacity. The capacity is increased when size exceeds the capacity. The new capacity is the product of the needed capacity and the given growthFactor.

By: Loic Rouchon

no subtypes hierarchy

Initializer
PriorityQueue(Comparison compare(Element x, Element y), Integer initialCapacity = 0, Float growthFactor = ..., {Element*} elements = ...)
Parameters:
  • compare

    A comparator function used to order elements.

  • initialCapacity = 0

    The initial size of the backing array.

  • growthFactor = 1.5

    The factor used to determine the new size of the backing array when a new backing array is allocated.

  • elements = {}

    The initial elements of the queue.

Attributes
backSource Codeshared actual Element? back

The element currently at the end of the queue, or null if the queue is empty. This is not necessarily the largest element (regarding the order relation defined by compare()) of the queue.

Refines Queue.back
frontSource Codeshared actual Element? front

The smallest element (regarding the order relation defined by compare()) of the queue, or null if the queue is empty.

Refines Queue.front
lastSource Codeshared actual Element? last

The element currently at the end of the queue, or null if the queue is empty. This is not necessarily the largest element (regarding the order relation defined by compare()) of the queue.

sizeSource Codeshared actual Integer size

The number of elements returned by the iterator of this stream, if the iterator terminates. In the case of an infinite stream, this operation never terminates.

Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Collection<Element>
Attributes inherited from: Iterable<Element,Absent>
Attributes inherited from: Queue<Element>
Methods
acceptSource Codeshared actual Element? accept()

Remove and return the smallest element (front element) from this queue

Refines Queue.accept
cloneSource Codeshared actual PriorityQueue<Element> clone()

A shallow copy of this collection, that is, a collection with identical elements which does not change if this collection changes. If this collection is immutable, it is acceptable to return a reference to this collection. If this collection is mutable, a newly instantiated collection must be returned.

iteratorSource Codeshared actual Iterator<Element> iterator()

An iterator for the elements belonging to this queue. Elements returned by this iterator are not ordered

offerSource Codeshared actual void offer(Element element)

Add a new element to the queue.

Refines Queue.offer
Inherited Methods
Methods inherited from: Object
Methods inherited from: Category<Element>
Methods inherited from: Collection<Element>
Methods inherited from: Iterable<Element,Absent>
Methods inherited from: Queue<Element>