本文整理汇总了C++中MyQueue::top方法的典型用法代码示例。如果您正苦于以下问题:C++ MyQueue::top方法的具体用法?C++ MyQueue::top怎么用?C++ MyQueue::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyQueue
的用法示例。
在下文中一共展示了MyQueue::top方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
MyQueue<int> q;
for(int i=0; i<10; ++i){
q.push(i);
}
q.pop();
q.pop();
q.push(10);
cout<< q.sintop() << ' ' << q.top() << endl;
return 0;
}
示例2: Test_7_QueueWithTwoStack
void Test_7_QueueWithTwoStack()
{
MyQueue q;
try
{
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
q.push(1);
try
{
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
q.push(2);
q.push(3);
try
{
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
try
{
q.pop();
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
try
{
q.pop();
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
try
{
q.pop();
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
try
{
q.pop();
cout << "top is " << q.top() << endl;
cout << "size is " << q.size() << endl;
}
catch (exception &e)
{
cout << e.what() << endl;
}
}
示例3: test
void test(){
int seq [6] = {0,0,0,0,0,0};
Board * start ;
Board * current;
int record=0;
initialize();
int step_size =0 ;
while(gen_next_recur(seq)){
record ++ ;
//if(record < 20)
// continue;
print_seq(seq);
for(int piindex = 0 ; piindex < PATTERN_NUM ;piindex++){
start = new Board();
start->init_with_sequence(seq,piindex);
open_list.push(start);
step_size =0;
while(!open_list.empty()){
current = open_list.top();
open_list.pop();
close_list.push(current);
//current->print();
if(current->is_goal()){
printf("Goal Found for pattern %d , step =%d\n",piindex,current->step);
//current->print();
break;
}
if(step_size<current->step){
step_size = current->step;
printf("%d\n",step_size);
}
for(int tile_id =0 ;tile_id < PATTERN_SIZE ;tile_id++){
for (int direc =0; direc < 4 ;direc++){
Board * tmp = current->gen_board(tile_id,direc);
if(tmp){
if(!close_list.exist(tmp)&&!open_list.exist(tmp)){
open_list.push(tmp);
}else
delete tmp;
}
}
}
}
write_db(seq,piindex,current->step);
while(!open_list.empty()){
current = open_list.top();
open_list.pop();
delete current;
}
while(!close_list.empty()){
current = close_list.top();
close_list.pop();
delete current;
}
//break;
}
//break;
}
}