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.

  • 相关阅读:
    SQL*PLUS命令的使用大全
    Oracle总结
    SQL*PLUS命令的使用大全
    Java经典面试题
    学习Java的30个基本概念
    Java经典面试题
    学习Java的30个基本概念
    Oracle总结
    ORACLE大数据量下的分页解决方法
    XAMPP修改80和443端口及创建虚拟目录
  • 原文地址:https://www.cnblogs.com/sssblog/p/11139066.html
Copyright © 2011-2022 走看看