BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR > Class Template Reference

#include <bslstl_priorityqueue.h>

Public Types

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

Public Member Functions

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

Public Attributes

void swap(priority_queue &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl bool empty () const
 

Protected Attributes

CONTAINER c
 
COMPARATOR comp
 

Detailed Description

template<class VALUE, class CONTAINER = vector<VALUE>, class COMPARATOR = std::less<typename CONTAINER::value_type>>
class bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >

This class is a value-semantic class template, adapting a container of the (template parameter) type CONTAINER, that holds elements of the (template parameter) type VALUE, to provide a highest-priority-first priority queue data structure, where the priorities of elements are compared by a comparator of the template parameter type, COMPARATOR. The container object held by a priority_queue class object is referenced as c in the following documentation.

See bslstl_priorityqueue

Member Typedef Documentation

◆ const_reference

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

◆ container_type

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

◆ reference

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

◆ size_type

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

◆ value_compare

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

◆ value_type

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

Constructor & Destructor Documentation

◆ priority_queue() [1/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( )
inline

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.

◆ priority_queue() [2/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator)
inlineexplicit

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.

◆ priority_queue() [3/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
const CONTAINER &  container 
)
inline

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.

◆ priority_queue() [4/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const COMPARATOR &  comparator,
BloombergLP::bslmf::MovableRef< CONTAINER >  container 
)
inlineexplicit

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.

◆ priority_queue() [5/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
template<class INPUT_ITERATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last 
)
inline

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.

◆ priority_queue() [6/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
template<class INPUT_ITERATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
const COMPARATOR &  comparator,
const CONTAINER &  container 
)
inline

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.

◆ priority_queue() [7/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inline

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.

◆ priority_queue() [8/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( const priority_queue< VALUE, CONTAINER, COMPARATOR > &  original)
inline

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.

◆ priority_queue() [9/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::priority_queue ( BloombergLP::bslmf::MovableRef< priority_queue< VALUE, CONTAINER, COMPARATOR > >  original)
inline

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.

◆ priority_queue() [10/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inlineexplicit

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.

◆ priority_queue() [11/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inline

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.

◆ priority_queue() [12/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inline

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.

◆ priority_queue() [13/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inline

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.

◆ priority_queue() [14/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inline

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.

◆ priority_queue() [15/15]

template<class VALUE , class CONTAINER , class COMPARATOR >
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 
)
inline

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.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF()

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   
)

◆ emplace()

template<class VALUE , class CONTAINER , class COMPARATOR >
template<class... Args>
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::emplace ( Args &&...  args)
inline

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)...);.

◆ operator=() [1/2]

template<class VALUE , class CONTAINER , class COMPARATOR >
priority_queue< VALUE, CONTAINER, COMPARATOR > & bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::operator= ( BloombergLP::bslmf::MovableRef< priority_queue< VALUE, CONTAINER, COMPARATOR > >  rhs)
inline

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.

◆ operator=() [2/2]

template<class VALUE , class CONTAINER , class COMPARATOR >
priority_queue< VALUE, CONTAINER, COMPARATOR > & bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::operator= ( const priority_queue< VALUE, CONTAINER, COMPARATOR > &  rhs)
inline

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

◆ pop()

template<class VALUE , class CONTAINER , class COMPARATOR >
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::pop ( )
inline

◆ push() [1/2]

template<class VALUE , class CONTAINER , class COMPARATOR >
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::push ( BloombergLP::bslmf::MovableRef< value_type value)
inline

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

◆ push() [2/2]

template<class VALUE , class CONTAINER , class COMPARATOR >
void bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::push ( const value_type value)
inline

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

◆ size()

template<class VALUE , class CONTAINER , class COMPARATOR >
priority_queue< VALUE, CONTAINER, COMPARATOR >::size_type bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::size ( ) const
inline

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

◆ top()

template<class VALUE , class CONTAINER , class COMPARATOR >
priority_queue< VALUE, CONTAINER, COMPARATOR >::const_reference bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::top ( ) const
inline

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.

Member Data Documentation

◆ c

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

◆ comp

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

◆ empty

template<class VALUE , class CONTAINER , class COMPARATOR >
bool bsl::priority_queue< VALUE, CONTAINER, COMPARATOR >::empty
inline

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. Return true if this priority_queue object contains no elements, and false otherwise. In effect, performs return c.empty();.


The documentation for this class was generated from the following file: