数据结构:思想与方法-翁惠玉-第六章.pptVIP

  • 7
  • 0
  • 约1.23万字
  • 约 82页
  • 2017-10-16 发布于浙江
  • 举报

数据结构:思想与方法-翁惠玉-第六章.ppt

* STL中的优先级队列 头文件:queue 类模版:priority_queue 实现方式:二叉堆 主要成员: Void push( const Object x) Const Object top() const Void pop() Bool empty() Void clear() * 使用实例 #include iostream #include queue using namespace std; int main() { priority_queueint q; q.push(10); q.push(1); q.push(5); q.push(8); q.push(0); q.push(4); q.push(9); q.push(7); q.push(3); q.push(6); q.push(2); while (!q.empty()) {cout q.top() ; q.pop();} return 0; } * 第6章 优先级队列 基本的优先级队列 二叉堆 D堆 归并优先级队列 STL中的优先级队列 排队系统的模拟 * 单服务台的排队系统 在单服务台系统中,先到达的顾客先获得服务,也肯定先离开 事件处理的次序是:顾客1到达、顾客1离开、顾客2到达、顾客2离开、……、顾客n到达、顾客n离开 只需要一个普通队列保存顾客到达信息

文档评论(0)

1亿VIP精品文档

相关文档