Priority_queue Flashcards

1
Q

Element access

top( )

A

accesses the top element
Parameters
(none)

Return value
Reference to the top element as if obtained by a call to c.front()

Complexity
Constant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Capacity

empty( )

A

checks whether the underlying container is empty
Parameters
(none)

Return value
true if the underlying container is empty, false otherwise

Complexity
Constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Capacity

size( )

A

returns the number of elements
Parameters
(none)

Return value
The number of elements in the container.

Complexity
Constant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Modifiers

push( )

A
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Modifiers

emplace( )

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Modifiers

pop( )

A

removes the top element
Parameters
(none)

Return value
(none)

Complexity
Logarithmic number of comparisons plus the complexity of Container::pop_back.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Modifiers

swap( )

A
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).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly