Graph Theory _ Topology Sequencing _ Exercise 1 (priority queue small top heap)

Source: Internet
Author: User

Priority_queue

Basic operation:

Empty () returns true if the queue is null

Pop () Delete the top element, delete the first element

Push () joins an element

Size () returns the number of elements owned in the priority queue

Top () returns the top element of the priority queue, returning the element with the highest priority in the priority queues ( #队列中为front () )

Back () returns the priority queue-tail element, returning the element with the lowest priority in the priority queue

In the default priority queue, high priority first-out team. In the default int type, the first team is the larger number.

Priority_queue<vector<int>, less<int> > pq1; Sorting using incrementing less<int> function objects
Priority_queue<deque<int>, greater<int> > pq2; Sorting by using the Decrement greater<int> function object

Declaration method: 1, common Method 2, custom priority 3, Structure declaration method

Header files: #include <queue> #include <functional>

Reference Blog: c++stl--priority queue, "original" Priority queue Priority_queue detailed

Graph Theory _ Topology Sequencing _ Exercise 1 (priority queue small top heap)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.