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.

  • 相关阅读:
    Spring
    数据库架构
    Spring
    Spring
    Spring
    服务的有状态和无状态(转)
    Java基础
    Ubuntu
    Ubuntu
    Ubuntu
  • 原文地址:https://www.cnblogs.com/sssblog/p/11139066.html
Copyright © 2011-2022 走看看