zoukankan      html  css  js  c++  java
  • boost algorithm

    BOost Algorithm provides algorithms that complement the algorithms from the standard library. Unlike Boost Range, Boost Algorithm doesn't introduce new concepts. The algorithms defined by Boost Algorithm resemble the algorithms from the standard library.

    #include <boost/algorithm/cxx11/one_of.hpp>
    #include <array>
    #include <iostream>
    
    using namespace boost::algorithm;
    
    int main() {
      std::array<int, 6> a{{0, 5, 2, 1, 4, 3}};
      atuo predicate = [](int i) { return i == 4; };
      std::cout.setf(std::ios::boolalpha);
      std::cout << one_of(a.begin(), a.end(), predicate) << std;:endl;
      std::cout << one_of_equal(a.begin(), a.end(), 4) << std::endl;
      return 0;
    }

    输出为:

    true

    true

     boost::algorithm::one_of() tests whether a condition is met exactly once. The condition to test is passed as a predicate.

    Boost Algorithm also defines the following functions: boost::algorithm::all_of_equal(), boost::algorithm::any_of_equal() and boost::algorithm::none_of_equal().

    Boost.Algorithm provides more algorithms from the C++11 standard library. For example, you have access to boost::algorithm::is_partitioned(), boost::algorithm::is_permutation(), boost::algorithm::copy_n(), boost::algorithm::find_if_not() and boost::algorithm::iota(). These  functions work like the indentically named functions from the C++11 standard library and are provided for developers who don't use C++11.

  • 相关阅读:
    我是如何用三小时搞出个赚钱产品的?
    搭建一个基于nuxt.js的项目
    栅格系统
    git使用
    通过JS获取屏幕高度,借助屏幕高度设置div的高度
    如何理解盒模型
    e.target.value 和 this 的区别
    组件化设计:弹窗的使用逻辑
    uni-app 入坑记
    MAC 系统快捷键
  • 原文地址:https://www.cnblogs.com/sssblog/p/11139066.html
Copyright © 2011-2022 走看看