zoukankan      html  css  js  c++  java
  • queue STL

    //queue STL
    //queue is just a container adaptor, which is a class that use other container.
    //just like stack
    q1.push(x)     //push x into the queue
    q1.pop()        //pop the first element in the queue
    q1.front()       //return the first element in the queue
    q1.back()        //return the last element in the queue
    q1.empty()      
    q1.size()
    
    //C++11
    q1.emplace(x)    //add a new element at the end of the queue, after its current last element 
    
    //the differences between emplace and push
    //though they are both the functions to add elements in the queue
    //if you use emplace ,you will not make a new class.
    //Let's see a example
    struct node
    {
    	int x, y;
    
    	node(int a, int b) :x(a), y(b){}
    };
    
    int main()
    {
    	queue<node>q1,q2;
    	q1.emplace(1, 2);
    	q2.push(node(1, 2));
    
    	cout << q1.front().x << endl;
    
    	return 0;
    }  
    

      

  • 相关阅读:
    python之元组
    python之dict
    python之list
    python之str字符串
    python之for循环
    Python的基本语法2
    Python的基本语法1
    初识python
    JS获取当天是周几
    EXCLE导入数据库
  • 原文地址:https://www.cnblogs.com/KennyRom/p/5956686.html
Copyright © 2011-2022 走看看