class template
<queue>
std::priority_queuetemplate <class T, class Container = vector<T>, class Compare = less<typename Container::value_type> > class priority_queue;
Priority queue
Priority queues are a type of container adaptors, specifically designed such that its first element is always the greatest of the elements it contains, according to some strict weak ordering criterion.This context is similar to a heap, where elements can be inserted at any moment, and only the max heap element can be retrieved (the one at the top in the priority queue).
Priority queues are implemented as container adaptors, which are classes that use an encapsulated object of a specific container class as its underlying container, providing a specific set of member functions to access its elements. Elements are popped from the "back" of the specific container, which is known as the top of the priority queue.
The underlying container may be any of the standard container class templates or some other specifically designed container class. The container shall be accessible through random access iterators and support the following operations:
Support of random access iterators is required to keep a heap structure internally at all times. This is done automatically by the container adaptor by automatically calling the algorithm functions make_heap, push_heap and pop_heap when needed.
bool
.
comp(a,b)
, where comp is an object of this type and a and b are elements in the container, shall return true
if a is considered to go before b in the strict weak ordering the function defines.
less<T>
, which returns the same as applying the less-than operator (a<b
).
value_type&
const_reference container_type::const_reference usually, const value_type&
size_type an unsigned integral type usually, the same as size_t
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4