摘要: 优先队列容器与队列一样,只能从队尾插入元素,从队首删除元素。但是它有一个特性,就是队列中最大的元素总是位于队首,所以出队时,并非按照先进先出的原则进行,而是将当前队列中最大的元素出队。这点类似于给队列里的元素进行了由大互小的顺序排序。元素的比较规则默认按元素值由大到小排序,可以重载“#include #include using namespace std;int main() { priority_queue q; // insert three elements into the priority queue q.push(66.6); q.push(22.2); q.push(44... 阅读全文
posted @ 2013-08-04 22:21 沙漠中的雨滴 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 二叉平衡查找树即是一棵树中所有节点的左右子树高度差不超过1的查找树头文件——————————————————————————————#ifndef _AVLTREE_H_#define _AVLTREE_H_#include #include #include typedefstructAvlNode *Position;typedefPosition AvlTree;#define Element intstructAvlNode{Element data;intheight;//叶子节点高度定义为0,其父节点为1以此类推AvlTree left;AvlTree right;};static 阅读全文
posted @ 2013-08-04 17:18 沙漠中的雨滴 阅读(206) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;typedef struct tagStudentInfo{int nID;string strName;bool operator setS;sInfo stuInfo;stuInfo.nID = 10;stuInfo.strName = "test1";setS.insert(stuInfo);stuInfo.nID = 20;stuInfo.strName = "test2";setS.insert(stuInfo);set::iterator sIter;for(sIte 阅读全文
posted @ 2013-08-04 17:07 沙漠中的雨滴 阅读(2181) 评论(0) 推荐(0) 编辑
摘要: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657(1)使用set/multiset之前必须包含头文件:#include(2)namespacestd{template,classAllocator = allocator >classset; template,classAllocator = allocator >classmultiset; }只要是assignable、copyable、comparable的型别T都 阅读全文
posted @ 2013-08-04 16:58 沙漠中的雨滴 阅读(139) 评论(0) 推荐(0) 编辑