本文整理汇总了C++中PriorityQueue::sort方法的典型用法代码示例。如果您正苦于以下问题:C++ PriorityQueue::sort方法的具体用法?C++ PriorityQueue::sort怎么用?C++ PriorityQueue::sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue::sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (){
PriorityQueue *m = new PriorityQueue();
arrayList *a = new arrayList();
for (int i = 0; i < 10; i++)
a->insert(i, 10-i);
m->initialize(a, 10);
cout<<"The inorder travesal is: ";
m->inOrder(0);
cout<<endl;
cout<<"The preorder travesal is: ";
m->preOrder(0);
cout<<endl;
cout<<"The postorder travesal is: ";
m->postOrder(0);
cout<<endl;
cout<<"The sorted list is: ";
m->sort();
cout<<endl;
}
示例2: main
int main (){
PriorityQueue *m = new PriorityQueue();
arrayList *a = new arrayList();
for (int i = 0; i < 10; i++)
a->insert(i, 10-i);
arrayList *b = new arrayList();
for (int j = 0; j < 20; j++)
b->insert(j, 20-j);
arrayList *c = new arrayList();
for (int i = 0; i < 17; i++)
c->insert(i, i%7);
m->initialize(a, 10); //Make priority queue
//m->initialize(b, 20); //Make priority queue
//m->initialize(c, 17); //Make priority queue
m->print();
cout<<"The inorder travesal is: ";
m->inOrder(0);
cout<<endl;
cout<<"The preorder travesal is: ";
m->preOrder(0);
cout<<endl;
cout<<"The postorder travesal is: ";
m->postOrder(0);
cout<<endl;
cout<<"The sorted list is: ";
m->sort();
cout<<endl;
}