Priority_queue Flashcards
Element access
top( )
accesses the top element
Parameters
(none)
Return value
Reference to the top element as if obtained by a call to c.front()
Complexity
Constant.
Capacity
empty( )
checks whether the underlying container is empty
Parameters
(none)
Return value
true if the underlying container is empty, false otherwise
Complexity
Constant
Capacity
size( )
returns the number of elements
Parameters
(none)
Return value
The number of elements in the container.
Complexity
Constant.
Modifiers
push( )
inserts element and sorts the underlying container Parameters value - the value of the element to push Return value (none)
Complexity
Logarithmic number of comparisons plus the complexity of Container::push_back
Modifiers
emplace( )
constructs element in-place and sorts the underlying container
Parameters
args - arguments to forward to the constructor of the element
Return value
(none)
Complexity
Logarithmic number of comparisons plus the complexity of Container::emplace_back.
Modifiers
pop( )
removes the top element
Parameters
(none)
Return value (none)
Complexity
Logarithmic number of comparisons plus the complexity of Container::pop_back.
Modifiers
swap( )
swaps the contents Parameters other - container adaptor to exchange the contents with Return value (none)
Exceptions
noexcept specification:
noexcept(noexcept(swap(c, other.c)) && noexcept(swap(comp, other.comp)))
In the expression above, the identifier swap is looked up in the same manner as the one used by the C++17 std::is_nothrow_swappable trait.
(since C++11) (until C++17) noexcept specification: noexcept(std::is_nothrow_swappable_v && std::is_nothrow_swappable_v) (since C++17) Complexity Same as underlying container (typically constant).