zoukankan      html  css  js  c++  java
  • STL: set相关算法

    本节的四个算法所接受的set,必须是有序区间(sorted range),元素值可以重复出现。也就是说,他们可以接受STL的set/multiset容器作为输入区间。

    set_union

    Unites all of the elements that belong to at least one of two sorted source ranges into a single, sorted destination range, where the ordering criterion may be specified by a binary predicate.

    template<class InputIterator1, class InputIterator2, class OutputIterator>
       OutputIterator set_union(
          InputIterator1 _First1, 
          InputIterator1 _Last1,
          InputIterator2 _First2, 
          InputIterator2 _Last2, 
          OutputIterator _Result
       );
    template<class InputIterator1, class InputIterator2, class OutputIterator, class BinaryPredicate>
       OutputIterator set_union(
          InputIterator1 _First1, 
          InputIterator1 _Last1,
          InputIterator2 _First2, 
          InputIterator2 _Last2, 
          OutputIterator _Result,
          BinaryPredicate _Comp
       );

    set_intersection

    Unites all of the elements that belong to both sorted source ranges into a single, sorted destination range, where the ordering criterion may be specified by a binary predicate.

    template<class InputIterator1, class InputIterator2, class OutputIterator>
       OutputIterator set_intersection(
          InputIterator1 _First1, 
          InputIterator1 _Last1,
          InputIterator2 _First2, 
          InputIterator2 _Last2, 
          OutputIterator _Result
       );
    template<class InputIterator1, class InputIterator2, class OutputIterator, class BinaryPredicate>
       OutputIterator set_intersection(
          InputIterator1 _First1, 
          InputIterator1 _Last1,
          InputIterator2 _First2, 
          InputIterator2 _Last2, 
          OutputIterator _Result,
          BinaryPredicate _Comp
       );

    set_difference

    Unites all of the elements that belong to one sorted source range, but not to a second sorted source range, into a single, sorted destination range, where the ordering criterion may be specified by a binary predicate.

    template<class InputIterator1, class InputIterator2, class OutputIterator>
       OutputIterator set_difference(
          InputIterator1 first1, 
          InputIterator1 last1,
          InputIterator2 first2, 
          InputIterator2 last2, 
          OutputIterator result
       );
    template<class InputIterator1, class InputIterator2, class OutputIterator, class BinaryPredicate>
       OutputIterator set_difference(
          InputIterator1 first1, 
          InputIterator1 last1,
          InputIterator2 first2, 
          InputIterator2 last2, 
          OutputIterator result,
          BinaryPredicate comp
       );

    set_symmetric_difference

    Unites all of the elements that belong to one, but not both, of the sorted source ranges into a single, sorted destination range, where the ordering criterion may be specified by a binary predicate.

    template<class InputIterator1, class InputIterator2, class OutputIterator>
       OutputIterator set_symmetric_difference(
          InputIterator1 _First1, 
          InputIterator1 _Last1,
          InputIterator2 _First2, 
          InputIterator2 _Last2, 
          OutputIterator _Result
       );
    template<class InputIterator1, class InputIterator2, class OutputIterator, class BinaryPredicate>
       OutputIterator set_symmetric_difference(
          InputIterator1 _First1, 
          InputIterator1 _Last1,
          InputIterator2 _First2, 
          InputIterator2 _Last2, 
          OutputIterator _Result,
          BinaryPredicate _Comp
       );
  • 相关阅读:
    4-12日 面向对象的组合和继承
    4-8日 递归和二分查找
    4-11 对象的交互 命名空间作用域
    [LeetCode]-algorithms-Reverse Integer
    [LeetCode]-algorithms-Longest Palindromic Substring
    [LeetCode]-algorithms-Median of Two Sorted Arrays
    [LeetCode]-algorithms-Longest Substring Without Repeating Characters
    [LeetCode]-algorithms-Add Two Numbers
    Java中创建String的两种方式
    Java中String为什么是不可变的
  • 原文地址:https://www.cnblogs.com/freewater/p/2948144.html
Copyright © 2011-2022 走看看