zoukankan      html  css  js  c++  java
  • STL:C++标准容器库deque

     他是一个双向队列,大部分内容和vector基本一致

     主要是需要注意它是双向的,可头插,可尾插

    int main()
    {
            deque<Student> deq_stu;
            deq_stu.push_back(Student("lisi",22));
            deq_stu.push_back(Student("wangwu",53));
            deq_stu.push_back(Student("zou",29));
            //头部插入
            deq_stu.push_front(Student("ziwen",23));
            //头部删除
            deq_stu.pop_front();
    
            vector<Student> vec_stu;
            vec_stu.push_back(Student("lisi",22));
            vec_stu.push_back(Student("wangwu",53));
            //查找
            deque<Student>::iterator it;
            it = search(deq_stu.begin(),deq_stu.end(),vec_stu.begin(),vec_stu.end(),cmpname);
            if(it != deq_stu.end())
            {
                cout<<"found"<<endl;
               it->showStu();
            }
            else
                cout<<"not found"<<endl;
    
            it = search(deq_stu.begin(),deq_stu.end(),vec_stu.begin(),vec_stu.end());
                    if(it != deq_stu.end())
                    {
                        cout<<"found"<<endl;
                       it->showStu();
                    }
                    else
                        cout<<"not found"<<endl;
    }
  • 相关阅读:
    oc结构
    iOS分类
    iOS协议
    缓存无底洞现象
    数据库备份,恢复
    PHP邮件发送库:Swiftmailer
    PHP分页组件:Paginator
    PHP验证码类
    PHP日期和时间处理组件-Carbon
    composer的一些操作
  • 原文地址:https://www.cnblogs.com/xiaozoui11cl/p/12786435.html
Copyright © 2011-2022 走看看