Algorithmic Solutions > LEDA > LEDA Guide > Simple,Basic, and Advanced Data Types > Advanced Data Types > Bounded Priority Queues

Bounded Priority Queues

The data type b_priority_queue is a variant of the data type Priority Queue. It can be used to store objects of an arbitrary type I together with an associated priority from a fixed interval [a..b] of ints.

Example

The following program shows how to use b_priority_queue.
#include <LEDA/core/b_prio.h>
#include <LEDA/core/string.h>

int main()
{
  leda::b_priority_queue<double> Q(1,5);
    //bounded priority queue with priorities between 1 and 5

  Q.insert(2.5,3);
  Q.insert(1.5,2);
  Q.insert(0.7,1);
  Q.insert(4.4,5);
  Q.insert(3.8,4);

  while (!Q.empty()) std::cout << Q.del_min() << std::endl;

  return 0;
}

Strengths

Disadvantages

  • priority type can only be int
  • priorities only from a fixed interval

Tip

Use Bounded Priority Queues to replace Priority Queue if your keys are from a fixed interval of ints.

 

See also:

Priority Queues


Manual Entries:

Manual Page Bounded Priority Queues

User Defined Parameter Types

LEDA Item Concept

Linear Orders

Hashed Types




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH