HP Integrity NonStop H-Series User Manual

Page 123

Advertising
background image

queue_five(aVector.begin(), aVector.end(), eventComparison);

Queues constructed out of vectors tend to be somewhat smaller, while queues constructed out of
deques can be somewhat faster, particularly if the number of elements in the queue varies widely
over the course of execution. However, these differences are slight, and either form will generally
work in most circumstances.

Because the priority queue data structure does not itself know how to construct iterators, very few
of the algorithms noted in

Chapter 13

can be used with priority queues. Instead of iterating over

values, a typical algorithm that uses a priority queue constructs a loop, which repeatedly pulls
values from the structure (using the top() and pop() operations) until the collection becomes empty
(tested using the empty() operation). The example program described in the next section will
illustrate this use.

Information on ...

Priority queues are implemented by internally building a data structure called a heap. Abstractly, a
heap is a binary tree in which every node possesses the property that the value associated with the
node is smaller than or equal to the value associated with either child node.

Advertising
This manual is related to the following products: