小试 priority_queue

#include <queue>
#include <iostream>
#include <algorithm>

using namespace std;

struct RouteNodePath
{
 
 
 RouteNodePath(){}
 RouteNodePath(int x, int y, int z, int o ):
     _inroadno(x),_outroadno(y),_flagstation(z),_miles(o){}
 
 
 
 inline friend
 operator == (const RouteNodePath &p ,const RouteNodePath &r)
 {
  return p._miles == r._miles;
 }
 
 inline friend
 operator < (const RouteNodePath &p ,const RouteNodePath &r)
 {
  return p._miles < r._miles;
 }
 
 int _inroadno;
 int _outroadno;
 int _flagstation;
 int _miles;
 vector<int> _path;
 
};


int main()
{
 /* test 1*/
 // int ia[9] = {0,23,0,5,634,63,64,64,6};
 // priority_queue<int> ipq(ia,ia+9);
 // cout<< "size = " << ipq.size()<<endl;
 //           
file://结果:
 //           
file://size = 9
 //
 // for(int i =0 ; i <= ipq.size() ;++i)
 //  cout<<ipq.top()<<' ';
 //  cout<<endl;
 //           
file://结果:
 //           
file://634 634 634 634 634 634 634 634 634 634
 //  
 // while(!ipq.empty())
 // {
 //  cout<<ipq.top()<<' ';
 //  ipq.pop();
 // }
 //           
file://结
 //           
file://634 64 64 63 23 6 5 0 0
 // 
 // cout<<endl;
 
 /* test 2 */
 priority_queue<RouteNodePath>  rnodepath;
 rnodepath.push(RouteNodePath(1,2,3,440));
 rnodepath.push(RouteNodePath(2,3,1,810));
 rnodepath.push(RouteNodePath(3,4,3,1040));
 rnodepath.push(RouteNodePath(5,1,3,1440));
 rnodepath.push(RouteNodePath(2,3,3,240));
 
 RouteNodePath aa = rnodepath.top();
 cout<<aa._miles<<endl;

 /* test 3 */
 priority_queue<RouteNodePath>  rnodepath2;
 const RouteNodePath *rnodepathpt = &(rnodepath.top());
 rnodepath2.push(*rnodepathpt);
 
 RouteNodePath bb = rnodepath.top();
 cout<<bb._miles<<endl;
 
 RouteNodePath cc = rnodepath2.top();
 cout<<cc._miles<<endl;
 
 /* test4 */
 
 


  
 
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值