Init
This commit is contained in:
71
cppdraft/set/cons.md
Normal file
71
cppdraft/set/cons.md
Normal file
@@ -0,0 +1,71 @@
|
||||
[set.cons]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.4 Associative containers [[associative]](associative#set.cons)
|
||||
|
||||
### 23.4.6 Class template set [[set]](set#cons)
|
||||
|
||||
#### 23.4.6.2 Constructors, copy, and assignment [set.cons]
|
||||
|
||||
[ð](#lib:set,constructor)
|
||||
|
||||
`constexpr explicit set(const Compare& comp, const Allocator& = Allocator());
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12866)
|
||||
|
||||
*Effects*: Constructs an empty set using the specified comparison object and allocator[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12870)
|
||||
|
||||
*Complexity*: Constant[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:set,constructor_)
|
||||
|
||||
`template<class InputIterator>
|
||||
constexpr set(InputIterator first, InputIterator last,
|
||||
const Compare& comp = Compare(), const Allocator& = Allocator());
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12883)
|
||||
|
||||
*Effects*: Constructs an emptyset using the specified comparison object and allocator,
|
||||
and inserts elements from the range
|
||||
[first, last)[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12891)
|
||||
|
||||
*Complexity*: Linear in N if the range
|
||||
[first, last)
|
||||
is already sorted with respect to comp and otherwise NlogN,
|
||||
where N islast - first[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:set,constructor__)
|
||||
|
||||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>
|
||||
constexpr set(from_range_t, R&& rg, const Compare& comp = Compare(),
|
||||
const Allocator& = Allocator());
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12909)
|
||||
|
||||
*Effects*: Constructs an empty set using the specified comparison object and allocator,
|
||||
and inserts elements from the range rg[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12914)
|
||||
|
||||
*Complexity*: Linear in N if rg is already sorted with respect to comp and
|
||||
otherwise NlogN, where N is ranges::distance(rg)[.](#6.sentence-1)
|
||||
152
cppdraft/set/difference.md
Normal file
152
cppdraft/set/difference.md
Normal file
@@ -0,0 +1,152 @@
|
||||
[set.difference]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#set.difference)
|
||||
|
||||
### 26.8.7 Set operations on sorted structures [[alg.set.operations]](alg.set.operations#set.difference)
|
||||
|
||||
#### 26.8.7.5 set_difference [set.difference]
|
||||
|
||||
[ð](#lib:set_difference)
|
||||
|
||||
`template<class InputIterator1, class InputIterator2,
|
||||
class OutputIterator>
|
||||
constexpr OutputIterator
|
||||
set_difference(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator>
|
||||
ForwardIterator
|
||||
set_difference(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result);
|
||||
|
||||
template<class InputIterator1, class InputIterator2,
|
||||
class OutputIterator, class Compare>
|
||||
constexpr OutputIterator
|
||||
set_difference(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result, Compare comp);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator, class Compare>
|
||||
ForwardIterator
|
||||
set_difference(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result, Compare comp);
|
||||
|
||||
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I1, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I1> S1, [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I2, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I2> S2,
|
||||
[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_difference_result<I1, O>
|
||||
ranges::set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R1, [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R2, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O,
|
||||
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_difference_result<borrowed_iterator_t<R1>, O>
|
||||
ranges::set_difference(R1&& r1, R2&& r2, O result,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I1, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I1> S1,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I2, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I2> S2,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") O, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<O> OutS, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
ranges::set_difference_result<I1, O>
|
||||
ranges::set_difference(Ep&& exec, I1 first1, S1 last1,
|
||||
I2 first2, S2 last2, O result, OutS result_last,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R1, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R2,
|
||||
[sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") OutR, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, iterator_t<OutR>, Comp, Proj1, Proj2>
|
||||
ranges::set_difference_result<borrowed_iterator_t<R1>, borrowed_iterator_t<OutR>>
|
||||
ranges::set_difference(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {},
|
||||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10673)
|
||||
|
||||
Let:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
comp be less{},
|
||||
and proj1 and proj2 be identity{} for the overloads with no parameters by those names;
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
M be the number of elements in [first1, last1)
|
||||
that are not present in [first2, last2);
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
result_last be result + M for the overloads with no parameter result_last or result_r;
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
N be min(M, result_last - result)[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10690)
|
||||
|
||||
*Preconditions*: The ranges [first1, last1) and [first2, last2) are sorted
|
||||
with respect to comp and proj1 or proj2, respectively[.](#2.sentence-1)
|
||||
|
||||
The resulting range does not overlap with either of the original ranges[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10696)
|
||||
|
||||
*Effects*: Copies N elements of the range [first1, last1)
|
||||
which are not present in the range [first2, last2)
|
||||
to the range [result, result + N)[.](#3.sentence-1)
|
||||
|
||||
The elements in the constructed range are sorted[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10703)
|
||||
|
||||
*Returns*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
result_last for the overloads in namespace std[.](#4.1.sentence-1)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
{last1, result + N} for the overloads in namespace ranges,
|
||||
if N is equal to M[.](#4.2.sentence-1)
|
||||
|
||||
- [(4.3)](#4.3)
|
||||
|
||||
Otherwise, {j1, result_last} for the overloads in namespace ranges,
|
||||
where the iterator j1 points to positions past the last copied or skipped elements
|
||||
in [first1, last1) and [first2, last2), respectively[.](#4.3.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10721)
|
||||
|
||||
*Complexity*: At most 2 * ((last1 - first1) + (last2 - first2)) - 1 comparisons and applications of each projection[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10726)
|
||||
|
||||
*Remarks*: If [first1, last1) contains m elements
|
||||
that are equivalent to each other and
|
||||
[first2, last2) contains n elements
|
||||
that are equivalent to them,
|
||||
the last max(mân,0) elements from [first1, last1)
|
||||
are copied to the output range, in order[.](#6.sentence-1)
|
||||
22
cppdraft/set/erasure.md
Normal file
22
cppdraft/set/erasure.md
Normal file
@@ -0,0 +1,22 @@
|
||||
[set.erasure]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.4 Associative containers [[associative]](associative#set.erasure)
|
||||
|
||||
### 23.4.6 Class template set [[set]](set#erasure)
|
||||
|
||||
#### 23.4.6.3 Erasure [set.erasure]
|
||||
|
||||
[ð](#lib:erase_if,set)
|
||||
|
||||
`template<class Key, class Compare, class Allocator, class Predicate>
|
||||
constexpr typename set<Key, Compare, Allocator>::size_type
|
||||
erase_if(set<Key, Compare, Allocator>& c, Predicate pred);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12930)
|
||||
|
||||
*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();
|
||||
152
cppdraft/set/intersection.md
Normal file
152
cppdraft/set/intersection.md
Normal file
@@ -0,0 +1,152 @@
|
||||
[set.intersection]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#set.intersection)
|
||||
|
||||
### 26.8.7 Set operations on sorted structures [[alg.set.operations]](alg.set.operations#set.intersection)
|
||||
|
||||
#### 26.8.7.4 set_intersection [set.intersection]
|
||||
|
||||
[ð](#lib:set_intersection)
|
||||
|
||||
`template<class InputIterator1, class InputIterator2,
|
||||
class OutputIterator>
|
||||
constexpr OutputIterator
|
||||
set_intersection(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator>
|
||||
ForwardIterator
|
||||
set_intersection(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result);
|
||||
|
||||
template<class InputIterator1, class InputIterator2,
|
||||
class OutputIterator, class Compare>
|
||||
constexpr OutputIterator
|
||||
set_intersection(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result, Compare comp);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator, class Compare>
|
||||
ForwardIterator
|
||||
set_intersection(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result, Compare comp);
|
||||
|
||||
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I1, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I1> S1, [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I2, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I2> S2,
|
||||
[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_intersection_result<I1, I2, O>
|
||||
ranges::set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R1, [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R2, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O,
|
||||
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
|
||||
ranges::set_intersection(R1&& r1, R2&& r2, O result,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I1, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I1> S1,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I2, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I2> S2,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") O, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<O> OutS, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
ranges::set_intersection_result<I1, I2, O>
|
||||
ranges::set_intersection(Ep&& exec, I1 first1, S1 last1,
|
||||
I2 first2, S2 last2, O result, OutS result_last,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R1, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R2,
|
||||
[sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") OutR, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, iterator_t<OutR>, Comp, Proj1, Proj2>
|
||||
ranges::set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>,
|
||||
borrowed_iterator_t<OutR>>
|
||||
ranges::set_intersection(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {},
|
||||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10546)
|
||||
|
||||
Let:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
comp be less{},
|
||||
and proj1 and proj2 be identity{} for the overloads with no parameters by those names;
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
M be the number of elements in [first1, last1)
|
||||
that are present in [first2, last2);
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
result_last be result + M for the overloads with no parameter result_last or result_r;
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
N be min(M, result_last - result)[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10563)
|
||||
|
||||
*Preconditions*: The ranges [first1, last1) and [first2, last2) are sorted
|
||||
with respect to comp and proj1 or proj2, respectively[.](#2.sentence-1)
|
||||
|
||||
The resulting range does not overlap with either of the original ranges[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10569)
|
||||
|
||||
*Effects*: Constructs a sorted intersection of N elements from the two ranges;
|
||||
that is, the set of elements that are present in both of the ranges[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10574)
|
||||
|
||||
*Returns*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
result_last for the overloads in namespace std[.](#4.1.sentence-1)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
{last1, last2, result + N} for the overloads in namespace ranges,
|
||||
if N is equal to M[.](#4.2.sentence-1)
|
||||
|
||||
- [(4.3)](#4.3)
|
||||
|
||||
Otherwise, {j1, j2, result_last} for the overloads in namespace ranges,
|
||||
where the iterators j1 and j2 point to positions past the last copied or skipped elements
|
||||
in [first1, last1) and [first2, last2), respectively[.](#4.3.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10592)
|
||||
|
||||
*Complexity*: At most 2 * ((last1 - first1) + (last2 - first2)) - 1 comparisons and applications of each projection[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10597)
|
||||
|
||||
*Remarks*: Stable ([[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms"))[.](#6.sentence-1)
|
||||
|
||||
If [first1, last1) contains m elements
|
||||
that are equivalent to each other and
|
||||
[first2, last2) contains n elements
|
||||
that are equivalent to them,
|
||||
the first min(m,n) elements
|
||||
are copied from the first range to the output range, in order[.](#6.sentence-2)
|
||||
59
cppdraft/set/modifiers.md
Normal file
59
cppdraft/set/modifiers.md
Normal file
@@ -0,0 +1,59 @@
|
||||
[set.modifiers]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.4 Associative containers [[associative]](associative#set.modifiers)
|
||||
|
||||
### 23.4.6 Class template set [[set]](set#modifiers)
|
||||
|
||||
#### 23.4.6.4 Modifiers [set.modifiers]
|
||||
|
||||
[ð](#lib:insert,set)
|
||||
|
||||
`template<class K> constexpr pair<iterator, bool> insert(K&& x);
|
||||
template<class K> constexpr iterator insert(const_iterator hint, K&& x);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12955)
|
||||
|
||||
*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") Compare::is_transparent is valid and denotes a type[.](#1.sentence-1)
|
||||
|
||||
For the second overload,is_convertible_v<K&&, const_iterator> andis_convertible_v<K&&, iterator> are both false[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12963)
|
||||
|
||||
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into set fromstd::forward<K>(x)[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12968)
|
||||
|
||||
*Effects*: If the set already contains an element that is equivalent to x,
|
||||
there is no effect[.](#3.sentence-1)
|
||||
|
||||
Otherwise, let r be equal_range(x)[.](#3.sentence-2)
|
||||
|
||||
Constructs an object u of type value_type with std::forward<K>(x)[.](#3.sentence-3)
|
||||
|
||||
If equal_range(u) == r is false, the behavior is undefined[.](#3.sentence-4)
|
||||
|
||||
Inserts u into *this[.](#3.sentence-5)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12978)
|
||||
|
||||
*Returns*: For the first overload,
|
||||
the bool component of the returned pair is true if and only if the insertion took place[.](#4.sentence-1)
|
||||
|
||||
The returned iterator points to the set element that is equivalent to x[.](#4.sentence-2)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12985)
|
||||
|
||||
*Complexity*: Logarithmic[.](#5.sentence-1)
|
||||
32
cppdraft/set/new/handler.md
Normal file
32
cppdraft/set/new/handler.md
Normal file
@@ -0,0 +1,32 @@
|
||||
[set.new.handler]
|
||||
|
||||
# 17 Language support library [[support]](./#support)
|
||||
|
||||
## 17.6 Dynamic memory management [[support.dynamic]](support.dynamic#set.new.handler)
|
||||
|
||||
### 17.6.4 Storage allocation errors [[alloc.errors]](alloc.errors#set.new.handler)
|
||||
|
||||
#### 17.6.4.4 set_new_handler [set.new.handler]
|
||||
|
||||
[ð](#lib:set_new_handler)
|
||||
|
||||
`new_handler set_new_handler(new_handler new_p) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3122)
|
||||
|
||||
*Effects*: Establishes the function designated by new_p as the currentnew_handler[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3127)
|
||||
|
||||
*Returns*: The previous new_handler[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L3131)
|
||||
|
||||
*Remarks*: The initial new_handler is a null pointer[.](#3.sentence-1)
|
||||
49
cppdraft/set/overview.md
Normal file
49
cppdraft/set/overview.md
Normal file
File diff suppressed because one or more lines are too long
165
cppdraft/set/symmetric/difference.md
Normal file
165
cppdraft/set/symmetric/difference.md
Normal file
@@ -0,0 +1,165 @@
|
||||
[set.symmetric.difference]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#set.symmetric.difference)
|
||||
|
||||
### 26.8.7 Set operations on sorted structures [[alg.set.operations]](alg.set.operations#set.symmetric.difference)
|
||||
|
||||
#### 26.8.7.6 set_symmetric_difference [set.symmetric.difference]
|
||||
|
||||
[ð](#lib:set_symmetric_difference)
|
||||
|
||||
`template<class InputIterator1, class InputIterator2,
|
||||
class OutputIterator>
|
||||
constexpr OutputIterator
|
||||
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator>
|
||||
ForwardIterator
|
||||
set_symmetric_difference(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result);
|
||||
|
||||
template<class InputIterator1, class InputIterator2,
|
||||
class OutputIterator, class Compare>
|
||||
constexpr OutputIterator
|
||||
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result, Compare comp);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator, class Compare>
|
||||
ForwardIterator
|
||||
set_symmetric_difference(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result, Compare comp);
|
||||
|
||||
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I1, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I1> S1, [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I2, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I2> S2,
|
||||
[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_symmetric_difference_result<I1, I2, O>
|
||||
ranges::set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
|
||||
Comp comp = {}, Proj1 proj1 = {},
|
||||
Proj2 proj2 = {});
|
||||
template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R1, [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R2, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O,
|
||||
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_symmetric_difference_result<borrowed_iterator_t<R1>,
|
||||
borrowed_iterator_t<R2>, O>
|
||||
ranges::set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
|
||||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I1, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I1> S1,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I2, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I2> S2,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") O, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<O> OutS, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
ranges::set_symmetric_difference_result<I1, I2, O>
|
||||
ranges::set_symmetric_difference(Ep&& exec, I1 first1, S1 last1,
|
||||
I2 first2, S2 last2, O result, OutS result_last,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R1, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R2,
|
||||
[sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") OutR, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, iterator_t<OutR>, Comp, Proj1, Proj2>
|
||||
ranges::set_symmetric_difference_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>,
|
||||
borrowed_iterator_t<OutR>>
|
||||
ranges::set_symmetric_difference(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10804)
|
||||
|
||||
Let:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
comp be less{},
|
||||
and proj1 and proj2 be identity{} for the overloads with no parameters by those names;
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
K be the number of elements in [first1, last1) that are not present in [first2, last2)[.](#1.2.sentence-1)
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
M be the number of elements in [first2, last2) that are not present in [first1, last1)[.](#1.3.sentence-1)
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
result_last be result + M + K for the overloads with no parameter result_last or result_r;
|
||||
|
||||
- [(1.5)](#1.5)
|
||||
|
||||
N be min(K+M, result_last - result)[.](#1.5.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10822)
|
||||
|
||||
*Preconditions*: The ranges [first1, last1) and [first2, last2) are sorted
|
||||
with respect to comp and proj1 or proj2, respectively[.](#2.sentence-1)
|
||||
|
||||
The resulting range does not overlap with either of the original ranges[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10828)
|
||||
|
||||
*Effects*: Copies the elements of the range [first1, last1)
|
||||
that are not present in the range [first2, last2),
|
||||
and the elements of the range [first2, last2)
|
||||
that are not present in the range [first1, last1)
|
||||
to the range [result, result + N)[.](#3.sentence-1)
|
||||
|
||||
The elements in the constructed range are sorted[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10837)
|
||||
|
||||
*Returns*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
result_last for the overloads in namespace std[.](#4.1.sentence-1)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
{last1, last2, result + N} for the overloads in namespace ranges,
|
||||
if N is equal to M+K[.](#4.2.sentence-1)
|
||||
|
||||
- [(4.3)](#4.3)
|
||||
|
||||
Otherwise, {j1, j2, result_last} for the overloads in namespace ranges,
|
||||
where the iterators j1 and j2 point to positions past the last copied or skipped elements
|
||||
in [first1, last1) and [first2, last2), respectively[.](#4.3.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10855)
|
||||
|
||||
*Complexity*: At most 2 * ((last1 - first1) + (last2 - first2)) - 1 comparisons and applications of each projection[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10860)
|
||||
|
||||
*Remarks*: Stable ([[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms"))[.](#6.sentence-1)
|
||||
|
||||
If [first1, last1) contains m elements
|
||||
that are equivalent to each other and
|
||||
[first2, last2) contains n elements
|
||||
that are equivalent to them,
|
||||
then |mân| of those elements shall be copied to the output range:
|
||||
the last mân of these elements from [first1, last1) if m>n, and
|
||||
the last nâm of these elements from [first2, last2) if m<n[.](#6.sentence-2)
|
||||
|
||||
In either case, the elements are copied in order[.](#6.sentence-3)
|
||||
33
cppdraft/set/terminate.md
Normal file
33
cppdraft/set/terminate.md
Normal file
@@ -0,0 +1,33 @@
|
||||
[set.terminate]
|
||||
|
||||
# 17 Language support library [[support]](./#support)
|
||||
|
||||
## 17.9 Exception handling [[support.exception]](support.exception#set.terminate)
|
||||
|
||||
### 17.9.5 Abnormal termination [[exception.terminate]](exception.terminate#set.terminate)
|
||||
|
||||
#### 17.9.5.2 set_terminate [set.terminate]
|
||||
|
||||
[ð](#lib:set_terminate)
|
||||
|
||||
`terminate_handler set_terminate(terminate_handler f) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4036)
|
||||
|
||||
*Effects*: Establishes the function designated by f as the current
|
||||
handler function for terminating exception processing[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4041)
|
||||
|
||||
*Returns*: The previous terminate_handler[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L4045)
|
||||
|
||||
*Remarks*: It is unspecified whether a null pointer value designates the defaultterminate_handler[.](#3.sentence-1)
|
||||
152
cppdraft/set/union.md
Normal file
152
cppdraft/set/union.md
Normal file
@@ -0,0 +1,152 @@
|
||||
[set.union]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#set.union)
|
||||
|
||||
### 26.8.7 Set operations on sorted structures [[alg.set.operations]](alg.set.operations#set.union)
|
||||
|
||||
#### 26.8.7.3 set_union [set.union]
|
||||
|
||||
[ð](#lib:set_union)
|
||||
|
||||
`template<class InputIterator1, class InputIterator2, class OutputIterator>
|
||||
constexpr OutputIterator
|
||||
set_union(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator>
|
||||
ForwardIterator
|
||||
set_union(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result);
|
||||
|
||||
template<class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
|
||||
constexpr OutputIterator
|
||||
set_union(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
OutputIterator result, Compare comp);
|
||||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||||
class ForwardIterator, class Compare>
|
||||
ForwardIterator
|
||||
set_union(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
ForwardIterator result, Compare comp);
|
||||
|
||||
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I1, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I1> S1, [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I2, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I2> S2,
|
||||
[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_union_result<I1, I2, O>
|
||||
ranges::set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
|
||||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R1, [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R2, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_incrementable [iterator.concept.winc]") O,
|
||||
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
|
||||
constexpr ranges::set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
|
||||
ranges::set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
|
||||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I1, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I1> S1,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I2, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I2> S2,
|
||||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") O, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<O> OutS, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<I1, I2, O, Comp, Proj1, Proj2>
|
||||
ranges::set_union_result<I1, I2, O>
|
||||
ranges::set_union(Ep&& exec, I1 first1, S1 last1,
|
||||
I2 first2, S2 last2, O result, OutS result_last,
|
||||
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R1, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R2,
|
||||
[sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") OutR, class Comp = ranges::less,
|
||||
class Proj1 = identity, class Proj2 = identity>
|
||||
requires [mergeable](alg.req.mergeable#concept:mergeable "24.3.7.7 Concept mergeable [alg.req.mergeable]")<iterator_t<R1>, iterator_t<R2>, iterator_t<OutR>, Comp, Proj1, Proj2>
|
||||
ranges::set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>,
|
||||
borrowed_iterator_t<OutR>>
|
||||
ranges::set_union(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {},
|
||||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10416)
|
||||
|
||||
Let:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
comp be less{},
|
||||
and proj1 and proj2 be identity{} for the overloads with no parameters by those names;
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
M be last1 - first1 plus the number of elements in [first2, last2)
|
||||
that are not present in [first1, last1);
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
result_last be result + M for the overloads with no parameter result_last or result_r;
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
N be min(M, result_last - result)[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10433)
|
||||
|
||||
*Preconditions*: The ranges [first1, last1) and [first2, last2) are sorted
|
||||
with respect to comp and proj1 or proj2, respectively[.](#2.sentence-1)
|
||||
|
||||
The resulting range does not overlap with either of the original ranges[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10439)
|
||||
|
||||
*Effects*: Constructs a sorted union of N elements from the two ranges;
|
||||
that is, the set of elements that are present in one or both of the ranges[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10444)
|
||||
|
||||
*Returns*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
result_last for the overloads in namespace std[.](#4.1.sentence-1)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
{last1, last2, result + N} for the overloads in namespace ranges,
|
||||
if N is equal to M[.](#4.2.sentence-1)
|
||||
|
||||
- [(4.3)](#4.3)
|
||||
|
||||
Otherwise, {j1, j2, result_last} for the overloads in namespace ranges,
|
||||
where the iterators j1 and j2 point to positions past the last copied or skipped elements
|
||||
in [first1, last1) and [first2, last2), respectively[.](#4.3.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10462)
|
||||
|
||||
*Complexity*: At most 2 * ((last1 - first1) + (last2 - first2)) - 1 comparisons and applications of each projection[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10467)
|
||||
|
||||
*Remarks*: Stable ([[algorithm.stable]](algorithm.stable "16.4.6.8 Requirements for stable algorithms"))[.](#6.sentence-1)
|
||||
|
||||
If [first1, last1) contains m elements
|
||||
that are equivalent to each other and
|
||||
[first2, last2) contains n elements
|
||||
that are equivalent to them,
|
||||
then all m elements from the first range
|
||||
are copied to the output range, in order, and
|
||||
then the final max(nâm,0) elements from the second range
|
||||
are copied to the output range, in order[.](#6.sentence-2)
|
||||
Reference in New Issue
Block a user