zoukankan      html  css  js  c++  java
  • STL容器用法速查表:list,vector,stack,queue,deque,priority_queue,set,map

    STL容器用法速查表:list,vector,stack,queue,deque,priority_queue,set,map

      list vector deque stack queue priority_queue

    set

    [unordered_set]

    map

    [unordered_map]

    multimap

    [unordered_multimap]

        contiguous storage double-ended queue LIFO FIFO 1st is greatest      
    Iterators       X X X      
    Element access push_back push_back push_back push push push      
    push_front   push_front            
    pop_back pop_back pop_back pop pop pop      
    pop_front   pop_front            
    front front front top front top      
    back back back   back        
      at(i) at(i)         at(key)  
    Modifiers assign assign assign            
    insert insert insert      

    insert

    emplace

    insert

    emplace(key,val)

     insert

    emplace(key,val)

    erase erase erase       erase

    erase(key)=>erasednum

    erase(it/ita,itb)=>it

    erase(key)=>int(多个)

    erase(it/ita,itb)=>it

    swap swap swap       swap swap(mapb) swap(mapb)
    clear clear clear       clear clear()  clear()
    Capacity resize resize resize            
    empty empty empty empty empty empty empty empty()  empty()
    Operations splice           find find(key)=>it  find(key)=>it(单个)
    remove           count count(key)  count(key)
    remove_if           equal_range equal_range  equal_range(pair)
    unique           upper_bound upper_bound  upper_bound
    merge           lower_bound lower_bound  lower_bound
    sort                
      reverse                

    List Operations

    list splice // it points to 2 | mylist1: 1 2 3 4 |mylist2: 10 20 30 
    mylist1.splice (it, mylist2); 
    // mylist1: 1 10 20 30 2 3 4 | mylist2 (empty)|"it" still points to 2 
    mylist2.splice (mylist2.begin(),mylist1, it); 
    // mylist1: 1 10 20 30 3 4 | mylist2: 2 | "it" is now invalid. 
    mylist1.splice ( mylist1.begin(), mylist1, it, mylist1.end()); 
    //"it" points now to 30 | mylist1: 30 3 4 1 10 20
    remove mylist.remove (value); 
    remove_if mylist.remove_if (function); 
    mylist.remove_if(class());
    unique bool same_integral_part (double first, double second) 
    { return ( int(first)==int(second) ); } 
    mylist.sort();             //  2.72,  3.14, 12.15, 12.77, 12.77, 
                                 // 15.3,  72.25, 72.25, 73.0,  73.35 
    mylist.unique();           //  2.72,  3.14, 12.15, 12.77 
                                 // 15.3,  72.25, 73.0,  73.35 
    mylist.unique (same_integral_part);  //  2.72,  3.14, 12.15 
                                           // 15.3,  72.25, 73.0
    merge first.sort(); 
    second.sort(); 
    first.merge(); 
    first.merge(second,mycomparison);
    sort  
    reverse  
     
    from: http://www.cnblogs.com/wei-li/p/3353143.html
  • 相关阅读:
    UVA 1515 Pool construction 最大流跑最小割
    BZOJ 1060: [ZJOI2007]时态同步 树形DP
    Codeforces Round #282 (Div. 1)B. Obsessive String KMP+DP
    BZOJ 4027: [HEOI2015]兔子与樱花 贪心
    BZOJ 2435: [Noi2011]道路修建 dfs搜图
    HDU 5297 Y sequence 容斥/迭代
    HDU 5296 Annoying problem dfs序 lca set
    HDU 5289 Assignment RMQ
    343D/Codeforces Round #200 (Div. 1) D. Water Tree dfs序+数据结构
    php mysqli扩展库之预处理操作
  • 原文地址:https://www.cnblogs.com/GarfieldEr007/p/5280807.html
Copyright © 2011-2022 走看看