zoukankan      html  css  js  c++  java
  • boost 循环缓冲区

    boost 循环缓冲区

    [cpp] view plaincopy在CODE上查看代码片派生到我的代码片
     
    1. #include <boost/circular_buffer.hpp>  
    2.   
    3. int _tmain(int argc, _TCHAR* argv[])  
    4. {  
    5.   
    6.     boost::circular_buffer<int> cb(3);  
    7.   
    8.     // Insert some elements into the buffer.  
    9.     cb.push_back(1);  
    10.     cb.push_back(2);  
    11.     cb.push_back(3);  
    12.   
    13.     int a = cb[0];  // a == 1  
    14.     int b = cb[1];  // b == 2  
    15.     int c = cb[2];  // c == 3  
    16.   
    17.     // The buffer is full now, pushing subsequent  
    18.     // elements will overwrite the front-most elements.  
    19.   
    20.     cb.push_back(4);  // Overwrite 1 with 4.  
    21.     cb.push_back(5);  // Overwrite 2 with 5.  
    22.   
    23.     // The buffer now contains 3, 4 and 5.  
    24.   
    25.     a = cb[0];  // a == 3  
    26.     b = cb[1];  // b == 4  
    27.     c = cb[2];  // c == 5  
    28.   
    29.     // Elements can be popped from either the front or the back.  
    30.   
    31.     cb.pop_back();  // 5 is removed.  
    32.     cb.pop_front(); // 3 is removed.  
    33.   
    34.     int d = cb[0];  // d == 4  
    35.   
    36.     return 0;  
    37. }  
  • 相关阅读:
    tensorflow中协调器 tf.train.Coordinator 和入队线程启动器 tf.train.start_queue_runners
    C++ 第八天
    C++ 第七天
    C++ 第四天
    c++ 编译报错汇总(随时更新)
    C++ 第二天
    C++ 第三天
    c++ 继承(二)
    c++ 继承(一)
    回调函数
  • 原文地址:https://www.cnblogs.com/lidabo/p/3906079.html
Copyright © 2011-2022 走看看