Quick Links:

bal | bbl | bdl | bsl

Classes | Typedefs | Functions | Variables

Component bslstl_priorityqueue
[Package bslstl]

Provide container adapter class template priority_queue. More...

Classes

class  bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >

Typedefs

typedef CONTAINER bsl::priority_queue::container_type
typedef COMPARATOR bsl::priority_queue::value_compare
typedef CONTAINER::value_type bsl::priority_queue::value_type
typedef CONTAINER::reference bsl::priority_queue::reference
typedef CONTAINER::const_reference bsl::priority_queue::const_reference
typedef CONTAINER::size_type bsl::priority_queue::size_type

Functions

 bsl::priority_queue::BSLMF_NESTED_TRAIT_DECLARATION_IF (priority_queue, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< container_type >::value)
 bsl::priority_queue::priority_queue ()
 bsl::priority_queue::priority_queue (const COMPARATOR &comparator)
 bsl::priority_queue::priority_queue (const COMPARATOR &comparator, const CONTAINER &container)
 bsl::priority_queue::priority_queue (const COMPARATOR &comparator, BloombergLP::bslmf::MovableRef< CONTAINER > container)
template<class INPUT_ITERATOR >
 bsl::priority_queue::priority_queue (INPUT_ITERATOR first, INPUT_ITERATOR last)
template<class INPUT_ITERATOR >
 bsl::priority_queue::priority_queue (INPUT_ITERATOR first, INPUT_ITERATOR last, const COMPARATOR &comparator, const CONTAINER &container)
template<class INPUT_ITERATOR >
 bsl::priority_queue::priority_queue (INPUT_ITERATOR first, INPUT_ITERATOR last, const COMPARATOR &comparator, BloombergLP::bslmf::MovableRef< CONTAINER > container)
 bsl::priority_queue::priority_queue (const priority_queue &original)
 bsl::priority_queue::priority_queue (BloombergLP::bslmf::MovableRef< priority_queue > original)
template<class ALLOCATOR >
 bsl::priority_queue::priority_queue (const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::priority_queue::priority_queue (const COMPARATOR &comparator, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::priority_queue::priority_queue (const COMPARATOR &comparator, const CONTAINER &container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::priority_queue::priority_queue (const COMPARATOR &comparator, BloombergLP::bslmf::MovableRef< CONTAINER > container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::priority_queue::priority_queue (const priority_queue &original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
template<class ALLOCATOR >
 bsl::priority_queue::priority_queue (BloombergLP::bslmf::MovableRef< priority_queue > original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
priority_queue & bsl::priority_queue::operator= (const priority_queue &rhs)
priority_queue & bsl::priority_queue::operator= (BloombergLP::bslmf::MovableRef< priority_queue > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false)
void bsl::priority_queue::push (const value_type &value)
void bsl::priority_queue::push (BloombergLP::bslmf::MovableRef< value_type > value)
template<class... Args>
void bsl::priority_queue::emplace (Args &&...args)
void bsl::priority_queue::pop ()
size_type bsl::priority_queue::size () const
const_reference bsl::priority_queue::top () const
template<class VALUE , class CONTAINER , class COMPARATOR >
void bsl::swap (priority_queue< VALUE, CONTAINER, COMPARATOR > &a, priority_queue< VALUE, CONTAINER, COMPARATOR > &b) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false)

Variables

CONTAINER bsl::priority_queue::c
COMPARATOR bsl::priority_queue::comp
void swap(priority_queue
&other)
BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl
bool 
bsl::priority_queue::empty () const

Detailed Description

Outline
Purpose:
Provide container adapter class template priority_queue.
Classes:
bsl::priority_queue template of highest-priority-first data structure
Canonical Header:
bsl_queue.h
See also:
Component bslstl_queue, Component bslstl_stack
Description:
This component defines a class template, bsl::priority_queue, holding a container (of a template parameter type, CONTAINER, containing elements of another template parameter type, VALUE), and adapting it to provide highest-priority-first priority queue data structure. The component takes a third template parameter type, COMPARATOR, for customized priorities comparison between two elements.
An instantiation of priority_queue is an allocator-aware, value-semantic type whose salient attributes are its size (number of held elements) and the sorted sequence of values (of held elements). If priority_queue is instantiated with a value type, that is not itself value-semantic, then it will not retain all of its value-semantic qualities. A priority_queue cannot be tested for equality, but its value type must be able to be tested for comparing less by its comparator type.
The priority_queue implemented here adheres to the C++11 standard when compiled with a C++11 compiler, and makes the best approximation when compiled with a C++03 compiler. In particular, for C++03 we emulate move semantics, but limit forwarding (in emplace) to const lvalues, and make no effort to emulate noexcept or initializer-lists.
Memory Allocation:
The type supplied as an ALLOCATOR template parameter in some of priority_queue constructors determines how the held container (of the (template parameter) type CONTAINER) will allocate memory. A priority_queue supports allocators meeting the requirements of the C++11 standard [17.6.3.5] as long as the held container does. In addition it supports scoped-allocators derived from the bslma::Allocator memory allocation protocol. Clients intending to use bslma-style allocators should use bsl::allocator as the ALLOCATOR template parameter, providing a C++11 standard-compatible adapter for a bslma::Allocator object.
VALUE and CONTAINER::value_type:
When the CONTAINER template parameter is omitted the VALUE template parameter specifies the value_type of bsl::vector, the default container type. The VALUE template has no other role.
For C++17 and later, the behavior is undefined unless: Prior to C++17, CONTAINER::value_type determines the contained value type and VALUE is simply ignored. The resulting code may work with instances of VALUE (e.g., VALUE is convertible to CONTAINER::value_type) or not (compiler errors).
Operations:
The C++11 standard [23.6.4] declares any container type supporting operations front, push_back, and pop_back can be used to instantiate the (template parameter) type CONTAINER. Below is a list of public methods of priority_queue class that are effectively implemented as calling the corresponding operations in the held container (referenced as c).
  +--------------------------------------+--------------------------+
  | Public methods in 'priority_queue'   | Operation in 'CONTAINER' |
  +======================================+==========================+
  | void push(const value_type& value);  | c.push_back(value);      |
  | void pop();                          | c.pop_back();            |
  | void emplace(Args&&... args)         | c.emplace_back(...)      |
  +--------------------------------------+--------------------------+
  | bool empty() const;                  | c.empty();               |
  | size_type size() const;              | c.size();                |
  | const_reference top() const;         | c.front();               |
  +--------------------------------------+--------------------------+
Usage:
In this section we show intended use of this component.
Example 1: Task Scheduler:
In this example, we will use the bsl::priority_queue class to implement a task scheduler that schedules a group of tasks based on their designated priorities.
Suppose we want to write a background process that runs tasks needed by foreground applications. Each task has a task id, a priority, and a function pointer that can be invoked by the background process. This background process has two threads: one thread (receiving thread) receives requests from other applications, passing required tasks to a task scheduler; the other thread (processing thread) runs the task scheduler, executing the tasks one-by-one from higher to lower priorities. To implement this functionality, we can use bsl::priority_queue in the task scheduler to buffer received, but as yet unprocessed, tasks. The task scheduler adds newly received tasks into the priority queue in the receiving thread, and extracts tasks from the priority queue for execution according to their priorities in the processing thread.
First, we define a TaskFunction type:
  typedef void (*TaskFunction)(int, int, int);
Then, we define a Task class, which contains a task id, a TaskFunction object and an associated task priority:
  class Task
      // This class represents a task that has an integer task id, a task
      // function, and an integer priority.  The smaller the numerical value
      // of a priority, the higher the priority.
  {
    private:
      // DATA
      int          d_taskId;          // task id

      TaskFunction d_taskFunction_p;  // task function

      int          d_priority;        // priority of the task

    public:
      // CREATORS
      explicit Task(int taskId, TaskFunction taskFunction, int priority);
          // Create a 'Task' object having the specified 'taskId', the
          // specified 'd_taskFunction_p', and the specified 'priority'.

      // ACCESSORS
      int getId() const;
          // Return the contained task id.

      int getPriority() const;
          // Return the priority of the task.

      TaskFunction getFunction() const;
          // Return the contained task function object.
  };

  // CREATORS
  Task::Task(int taskId, TaskFunction taskFunction, int priority)
  : d_taskId(taskId)
  , d_taskFunction_p(taskFunction)
  , d_priority(priority)
  {
  }

  // ACCESSORS
  inline
  int Task::getId() const
  {
      return d_taskId;
  }

  inline
  int Task::getPriority() const
  {
      return d_priority;
  }

  inline
  TaskFunction Task::getFunction() const
  {
      return d_taskFunction_p;
  }
Next, we define a functor to compare the priorities of two Task objects:
  struct TaskComparator {
      // This 'struct' defines an ordering on 'Task' objects, allowing them
      // to be included in sorted data structures such as
      // 'bsl::priority_queue'.

      bool operator()(const Task& lhs, const Task& rhs) const
          // Return 'true' if the priority of the specified 'lhs' is
          // numerically less than that of the specified 'rhs', and 'false'
          // otherwise.  Note that the smaller the value returned by the
          // 'Task::getPriority' method, the higher the priority.
      {
          return lhs.getPriority() > rhs.getPriority();
      }
  };
Then, we define a TaskScheduler class that provides methods to hold and schedule unprocessed tasks:
  class TaskScheduler {
      // This class holds and schedules tasks to execute.
Here, we define a private data member that is an instantiation of bsl::priority_queue, which uses Task for its VALUE (template parameter) type, bsl::vector<Task> for its CONTAINER (template parameter) type, and TaskComparator for its COMPARATOR (template parameter) type:
      // DATA
      bsl::priority_queue<Task,
                          bsl::vector<Task>,
                          TaskComparator>
            d_taskPriorityQueue;  // priority queue holding unprocessed tasks

      // ...

    public:
      // CREATORS
      explicit TaskScheduler(bslma::Allocator *basicAllocator = 0);
          // Create a 'TaskScheduler' object.  Optionally specify a
          // 'basicAllocator' used to supply memory.  If 'basicAllocator' is
          // 0, the currently installed default allocator is used.

      // MANIPULATORS
      void addTask(int taskId, TaskFunction taskFunction, int priority);
          // Enqueue the specified 'task' having the specified 'priority'
          // onto this scheduler.

      void processTasks(int verbose);
          // Dequeue the task having the highest priority in this scheduler,
          // and call its task function by passing in the specified 'verbose'
          // flag.
  };
Next, we implement the TaskScheduler constructor:
  TaskScheduler::TaskScheduler(bslma::Allocator *basicAllocator)
  : d_taskPriorityQueue(basicAllocator)
  {
  }
Notice that we pass to the contained d_taskPriorityQueue object the bslma::Allocator supplied to the TaskScheduler at construction.
Then, we implement the addTask method, which constructs a Task object and adds it into the priority queue:
  void TaskScheduler::addTask(int taskId,
                              TaskFunction taskFunction,
                              int priority)
  {
      // ... (some synchronization)

      d_taskPriorityQueue.push(Task(taskId, taskFunction, priority));

      // ...
  }
Next, we implement the processTasks method, which extracts tasks from the priority queue in order of descending priorities, and executes them:
  void TaskScheduler::processTasks(int verbose)
  {
      // ... (some synchronization)

      while (!d_taskPriorityQueue.empty()) {
          const Task& task = d_taskPriorityQueue.top();
          TaskFunction taskFunction = task.getFunction();
          if (taskFunction) {
              taskFunction(task.getId(), task.getPriority(), verbose);
          }
          d_taskPriorityQueue.pop();
      }

      // ...
  }
Note that the top method always returns the Task object having the highest priority in the priority queue.
Then, we define two task functions:
  void taskFunction1(int taskId, int priority, int verbose)
  {
      if (verbose) {
          printf("Executing task %d (priority = %d) in 'taskFunction1'.\n",
                 taskId,
                 priority);
      }
  }

  void taskFunction2(int taskId, int priority, int verbose)
  {
      if (verbose) {
          printf("Executing task %d (priority = %d) in 'taskFunction2'.\n",
                 taskId,
                 priority);
      }
  }
Next, we create a global TaskScheduler object:
  TaskScheduler taskScheduler;
Now, we call the addTask method of taskScheduler in the receiving thread:
  // (in receiving thread)
  // ...

  taskScheduler.addTask(1, taskFunction1, 50);

  // ...

  taskScheduler.addTask(2, taskFunction1, 99);

  // ...

  taskScheduler.addTask(3, taskFunction2, 4);

  // ...
Finally, we call the processTasks method of taskScheduler in the processing thread:
  // (in processing thread)
  // ...

  taskScheduler.processTasks(veryVerbose);

  // ...

Typedef Documentation

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
typedef CONTAINER bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::container_type [inherited]
template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
typedef COMPARATOR bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::value_compare [inherited]
template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
typedef CONTAINER::value_type bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::value_type [inherited]
template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
typedef CONTAINER::reference bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::reference [inherited]
template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
typedef CONTAINER::const_reference bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::const_reference [inherited]
template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
typedef CONTAINER::size_type bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::size_type [inherited]

Function Documentation

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( priority_queue< VALUE, CONTAINER, COMPARATOR >  ,
BloombergLP::bslma::UsesBslmaAllocator  ,
BloombergLP::bslma::UsesBslmaAllocator< container_type >::value   
) [inherited]
template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue (  )  [inherited]

Create an empty priority queue, adapting a default-constructed container of the (template parameter) type CONTAINER. Use a default-constructed comparator of the (template parameter) type COMPARATOR to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator  )  [explicit, inherited]

Create an empty priority queue, adapting a default-constructed container of the (template parameter) type CONTAINER, and having the specified comparator of the (template parameter) type COMPARATOR to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
const CONTAINER &  container 
) [inherited]

Create a priority queue, adapting the specified container of the (template parameter) type CONTAINER, and having the specified comparator of the (template parameter) type COMPARATOR to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
BloombergLP::bslmf::MovableRef< CONTAINER >  container 
) [explicit, inherited]

Create a priority queue, adapting the specified container of the (template parameter) type CONTAINER, and having the specified comparator of the (template parameter) type COMPARATOR to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class INPUT_ITERATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last 
) [inherited]

Create a priority queue, adapting a default-constructed container of the (template parameter) type CONTAINER, and inserting into the container a sequence of value_type elements that starts at the specified first and ends immediately before the specified last. Use a default-constructed comparator of the (template parameter) type COMPARATOR to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class INPUT_ITERATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
const COMPARATOR &  comparator,
const CONTAINER &  container 
) [inherited]

Create a priority queue, adapting the specified container, having the specified comparator to order the priorities of elements, including those originally existed in container, and those inserted into the container from a sequence of value_type elements starting at the specified first, and ending immediately before the specified last.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class INPUT_ITERATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
const COMPARATOR &  comparator,
BloombergLP::bslmf::MovableRef< CONTAINER >  container 
) [inherited]

Create a priority queue, adapting the specified container, having the specified comparator to order elements in the priority queue, including those originally existed in container, and those inserted into the container from a sequence of value_type elements starting at the specified first, and ending immediately before the specified last.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const priority_queue< VALUE, CONTAINER, COMPARATOR > &  original  )  [inherited]

Create a priority queue having the same value as the specified original object. Use a copy of the comparator from original to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( BloombergLP::bslmf::MovableRef< priority_queue< VALUE, CONTAINER, COMPARATOR > >  original  )  [inherited]

Create a priority queue having the same value as the specified original object. Use a copy of the comparator from original to order elements in the priority queue.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class ALLOCATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [explicit, inherited]

Create an empty priority queue, adapting a default-constructed container of the (template parameter) type CONTAINER that uses the specified basicAllocator to supply memory. Use a default-constructed object of the (template parameter) type COMPARATOR to order elements in the priority queue. Note that this constructor is only defined if the underlying container uses allocator. Otherwise this constructor is disabled.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class ALLOCATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

Create an empty priority queue, adapting a default-constructed container of the (template parameter) type CONTAINER that uses the specified basicAllocator to supply memory, and the specified comparator to order elements in the priority queue. Note that this constructor is only defined if the underlying container uses allocator. Otherwise this constructor is disabled.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class ALLOCATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
const CONTAINER &  container,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

Create a priority queue, adapting the specified container that uses the specified basicAllocator to supply memory, and the specified comparator to order elements in the priority queue. Note that this constructor is only defined if the underlying container uses allocator. Otherwise this constructor is disabled.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class ALLOCATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
BloombergLP::bslmf::MovableRef< CONTAINER >  container,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

Create a priority queue, adapting the specified container that uses the specified basicAllocator to supply memory, and the specified comparator to order elements in the priority queue. Note that this constructor is only defined if the underlying container uses allocator. Otherwise this constructor is disabled.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class ALLOCATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const priority_queue< VALUE, CONTAINER, COMPARATOR > &  original,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

Create a priority queue having the same value as the specified original object and using the specified basicAllocator to supply memory. Use a copy of the comparator from original to order elements in the priority queue. Note that this constructor is only defined if the underlying container uses allocator. Otherwise this constructor is disabled.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class ALLOCATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( BloombergLP::bslmf::MovableRef< priority_queue< VALUE, CONTAINER, COMPARATOR > >  original,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type = 0 
) [inherited]

Create a priority queue having the same value as the specified original object and using the specified basicAllocator to supply memory. Use a copy of the comparator from original to order elements in the priority queue. Note that this constructor is only defined if the underlying container uses allocator. Otherwise this constructor is disabled.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
priority_queue& bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::operator= ( const priority_queue< VALUE, CONTAINER, COMPARATOR > &  rhs  )  [inherited]

Assign to this object the value and comparator of the specified rhs object and return a reference providing modifiable access to this object.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
priority_queue& bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::operator= ( BloombergLP::bslmf::MovableRef< priority_queue< VALUE, CONTAINER, COMPARATOR > >  rhs  )  [inherited]

Assign to this object the value and comparator of the specified rhs object and return a reference providing modifiable access to this object. rhs is left in a valid but unspecified state.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::push ( const value_type value  )  [inherited]

Insert the specified value into this priority queue. In effect, performs c.push_back(value);.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::push ( BloombergLP::bslmf::MovableRef< value_type value  )  [inherited]

Insert the specified value into this priority queue. In effect, performs c.push_back(value);.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
template<class... Args>
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::emplace ( Args &&...  args  )  [inherited]

Insert into this priority queue a newly created value_type object, constructed by forwarding the specified (variable number of) args to the corresponding constructor of value_type. In effect, performs c.emplace_back(FORWARD(Args,args)...);.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::pop (  )  [inherited]

Remove the top element from this priority_queue object that has the highest priority. In effect, performs c.pop_back();. The behavior is undefined if there is currently no elements in this object.

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
size_type bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::size (  )  const [inherited]

Return the number of elements in this priority_queue object. In effect, performs return c.size().

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
const_reference bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::top (  )  const [inherited]

Return a reference providing non-modifiable access to the element having the highest priority in this priority_queue object. In effect, performs return c.front(). The behavior is undefined if the priority queue is empty.

template<class VALUE , class CONTAINER , class COMPARATOR >
void bsl::swap ( priority_queue< VALUE, CONTAINER, COMPARATOR > &  a,
priority_queue< VALUE, CONTAINER, COMPARATOR > &  b 
)

Exchange the container and comparator of the specified a object with the container and comparator of the specified b object.


Variable Documentation

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
CONTAINER bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::c [protected, inherited]

container for elements in the priority_queue. This

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
COMPARATOR bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::comp [protected, inherited]

comparator that defines the priority order of elements

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
void swap (priority_queue& other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( bsl bool bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::empty() const [inherited]

< Efficiently exchange the value of this object with the value of the specified other object. In effect, performs 'using bsl::swap; swap(c, other.c);'. Return true if this priority_queue object contains no elements, and false otherwise. In effect, performs return c.empty();.