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.

  • 相关阅读:
    Linux查看当前系统的发行版信息
    用 CentOS 7 打造合适的科研环境
    消息队列的使用场景
    RabbitMQ几种Exchange 模式
    JMS规范概览
    消息队列的学习
    springMVC参数传递实例
    java8时间处理实例
    windows电脑常用必备软件
    http后台json解析实例
  • 原文地址:https://www.cnblogs.com/sssblog/p/11139066.html
Copyright © 2011-2022 走看看