中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > C/C++
小试 priority_queue
作者:未知 时间:2005-09-13 23:27 出处:Blog.ChinaUnix.net 责编:chinaitpower
              摘要:小试 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] = ;
 // 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 */
 
 

 
  
 
}


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有