Brian Silverman | 598d029 | 2018-08-04 23:56:47 -0700 | [diff] [blame^] | 1 | [/ |
| 2 | Copyright 2010 Neil Groves |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | /] |
| 6 | [section:set_union set_union] |
| 7 | |
| 8 | [heading Prototype] |
| 9 | |
| 10 | `` |
| 11 | template< |
| 12 | class SinglePassRange1, |
| 13 | class SinglePassRange2, |
| 14 | class OutputIterator |
| 15 | > |
| 16 | OutputIterator set_union(const SinglePassRange1& rng1, |
| 17 | const SinglePassRange2& rng2, |
| 18 | OutputIterator out); |
| 19 | |
| 20 | template< |
| 21 | class SinglePassRange1, |
| 22 | class SinglePassRange2, |
| 23 | class OutputIterator, |
| 24 | class BinaryPredicate |
| 25 | > |
| 26 | OutputIterator set_union(const SinglePassRange1& rng1, |
| 27 | const SinglePassRange2& rng2, |
| 28 | OutputIterator out, |
| 29 | BinaryPredicate pred); |
| 30 | `` |
| 31 | |
| 32 | [heading Description] |
| 33 | |
| 34 | `set_union` constructs a sorted range that is the union of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range. |
| 35 | The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. |
| 36 | |
| 37 | [heading Definition] |
| 38 | |
| 39 | Defined in the header file `boost/range/algorithm/set_algorithm.hpp` |
| 40 | |
| 41 | [heading Requirements] |
| 42 | |
| 43 | [*For the non-predicate versions:] |
| 44 | |
| 45 | * `SinglePassRange1` is a model of the __single_pass_range__ Concept. |
| 46 | * `SinglePassRange2` is a model of the __single_pass_range__ Concept. |
| 47 | * `OutputIterator` is a model of the `OutputIteratorConcept`. |
| 48 | * `SinglePassRange1` and `SinglePassRange2` have the same value type. |
| 49 | * `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. |
| 50 | * `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. |
| 51 | * The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. |
| 52 | * The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. |
| 53 | |
| 54 | [*For the predicate versions:] |
| 55 | |
| 56 | * `SinglePassRange1` is a model of the __single_pass_range__ Concept. |
| 57 | * `SinglePassRange2` is a model of the __single_pass_range__ Concept. |
| 58 | * `OutputIterator` is a model of the `OutputIteratorConcept`. |
| 59 | * `SinglePassRange1` and `SinglePassRange2` have the same value type. |
| 60 | * `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. |
| 61 | * `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. |
| 62 | * `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types. |
| 63 | |
| 64 | [heading Precondition:] |
| 65 | |
| 66 | [*For the non-predicate versions:] |
| 67 | |
| 68 | `rng1` and `rng2` are sorted in ascending order according to `operator<`. |
| 69 | |
| 70 | [*For the predicate versions:] |
| 71 | |
| 72 | `rng1` and `rng2` are sorted in ascending order according to `pred`. |
| 73 | |
| 74 | [heading Complexity] |
| 75 | |
| 76 | Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`. |
| 77 | |
| 78 | [endsect] |
| 79 | |
| 80 | |