tmp/tmpygz8ov5k/{from.md → to.md}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
## C library algorithms <a id="alg.c.library">[[alg.c.library]]</a>
|
| 2 |
|
| 3 |
-
[*Note 1*: The header `<cstdlib>`
|
| 4 |
-
|
| 5 |
|
| 6 |
``` cpp
|
| 7 |
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
| 8 |
c-compare-pred* compar);
|
| 9 |
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
|
@@ -13,22 +13,24 @@ void qsort(void* base, size_t nmemb, size_t size, compare-pred* compar);
|
|
| 13 |
```
|
| 14 |
|
| 15 |
*Effects:* These functions have the semantics specified in the C
|
| 16 |
standard library.
|
| 17 |
|
| 18 |
-
*
|
| 19 |
-
|
| 20 |
|
| 21 |
-
*Throws:* Any exception thrown by
|
| 22 |
-
|
| 23 |
|
| 24 |
ISO C 7.22.5.
|
| 25 |
|
| 26 |
<!-- Link reference definitions -->
|
|
|
|
|
|
|
| 27 |
[alg.adjacent.find]: #alg.adjacent.find
|
| 28 |
-
[alg.
|
| 29 |
-
[alg.
|
| 30 |
[alg.binary.search]: #alg.binary.search
|
| 31 |
[alg.c.library]: #alg.c.library
|
| 32 |
[alg.clamp]: #alg.clamp
|
| 33 |
[alg.copy]: #alg.copy
|
| 34 |
[alg.count]: #alg.count
|
|
@@ -38,17 +40,17 @@ ISO C 7.22.5.
|
|
| 38 |
[alg.find.end]: #alg.find.end
|
| 39 |
[alg.find.first.of]: #alg.find.first.of
|
| 40 |
[alg.foreach]: #alg.foreach
|
| 41 |
[alg.generate]: #alg.generate
|
| 42 |
[alg.heap.operations]: #alg.heap.operations
|
| 43 |
-
[alg.
|
| 44 |
[alg.lex.comparison]: #alg.lex.comparison
|
| 45 |
[alg.merge]: #alg.merge
|
| 46 |
[alg.min.max]: #alg.min.max
|
| 47 |
[alg.modifying.operations]: #alg.modifying.operations
|
| 48 |
[alg.move]: #alg.move
|
| 49 |
-
[alg.
|
| 50 |
[alg.nonmodifying]: #alg.nonmodifying
|
| 51 |
[alg.nth.element]: #alg.nth.element
|
| 52 |
[alg.partitions]: #alg.partitions
|
| 53 |
[alg.permutation.generators]: #alg.permutation.generators
|
| 54 |
[alg.random.sample]: #alg.random.sample
|
|
@@ -57,13 +59,15 @@ ISO C 7.22.5.
|
|
| 57 |
[alg.replace]: #alg.replace
|
| 58 |
[alg.reverse]: #alg.reverse
|
| 59 |
[alg.rotate]: #alg.rotate
|
| 60 |
[alg.search]: #alg.search
|
| 61 |
[alg.set.operations]: #alg.set.operations
|
|
|
|
| 62 |
[alg.sort]: #alg.sort
|
| 63 |
[alg.sorting]: #alg.sorting
|
| 64 |
[alg.swap]: #alg.swap
|
|
|
|
| 65 |
[alg.transform]: #alg.transform
|
| 66 |
[alg.unique]: #alg.unique
|
| 67 |
[algorithm.stable]: library.md#algorithm.stable
|
| 68 |
[algorithm.syn]: #algorithm.syn
|
| 69 |
[algorithms]: #algorithms
|
|
@@ -73,70 +77,120 @@ ISO C 7.22.5.
|
|
| 73 |
[algorithms.parallel.exceptions]: #algorithms.parallel.exceptions
|
| 74 |
[algorithms.parallel.exec]: #algorithms.parallel.exec
|
| 75 |
[algorithms.parallel.overloads]: #algorithms.parallel.overloads
|
| 76 |
[algorithms.parallel.user]: #algorithms.parallel.user
|
| 77 |
[algorithms.requirements]: #algorithms.requirements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
[bidirectional.iterators]: iterators.md#bidirectional.iterators
|
| 79 |
[binary.search]: #binary.search
|
| 80 |
-
[class.conv]:
|
| 81 |
[containers]: containers.md#containers
|
| 82 |
-
[conv]:
|
| 83 |
-
[conv.integral]:
|
| 84 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
[equal.range]: #equal.range
|
|
|
|
| 86 |
[execpol]: utilities.md#execpol
|
|
|
|
|
|
|
| 87 |
[forward.iterators]: iterators.md#forward.iterators
|
| 88 |
[function.objects]: utilities.md#function.objects
|
| 89 |
[includes]: #includes
|
|
|
|
|
|
|
| 90 |
[input.iterators]: iterators.md#input.iterators
|
| 91 |
-
[intro.execution]:
|
| 92 |
-
[intro.
|
|
|
|
| 93 |
[is.heap]: #is.heap
|
| 94 |
[is.sorted]: #is.sorted
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
[iterator.requirements]: iterators.md#iterator.requirements
|
| 96 |
[iterator.requirements.general]: iterators.md#iterator.requirements.general
|
| 97 |
[lower.bound]: #lower.bound
|
| 98 |
[make.heap]: #make.heap
|
| 99 |
[mismatch]: #mismatch
|
| 100 |
[multiset]: containers.md#multiset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
[output.iterators]: iterators.md#output.iterators
|
| 102 |
[partial.sort]: #partial.sort
|
| 103 |
[partial.sort.copy]: #partial.sort.copy
|
|
|
|
| 104 |
[pop.heap]: #pop.heap
|
| 105 |
[push.heap]: #push.heap
|
| 106 |
[rand.req.urng]: numerics.md#rand.req.urng
|
| 107 |
[random.access.iterators]: iterators.md#random.access.iterators
|
|
|
|
|
|
|
| 108 |
[refwrap]: utilities.md#refwrap
|
| 109 |
[res.on.exception.handling]: library.md#res.on.exception.handling
|
| 110 |
[set.difference]: #set.difference
|
| 111 |
[set.intersection]: #set.intersection
|
| 112 |
[set.symmetric.difference]: #set.symmetric.difference
|
| 113 |
[set.union]: #set.union
|
| 114 |
[sort]: #sort
|
| 115 |
[sort.heap]: #sort.heap
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
[stable.sort]: #stable.sort
|
| 117 |
[swappable.requirements]: library.md#swappable.requirements
|
| 118 |
-
[
|
| 119 |
-
[
|
| 120 |
-
[tab:copyconstructible]: #tab:copyconstructible
|
| 121 |
-
[tab:lessthancomparable]: #tab:lessthancomparable
|
| 122 |
-
[tab:moveassignable]: #tab:moveassignable
|
| 123 |
-
[tab:moveconstructible]: #tab:moveconstructible
|
| 124 |
[thread.thread.class]: thread.md#thread.thread.class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
[upper.bound]: #upper.bound
|
| 126 |
|
| 127 |
[^1]: The decision whether to include a copying version was usually
|
| 128 |
based on complexity considerations. When the cost of doing the
|
| 129 |
operation dominates the cost of copy, the copying version is not
|
| 130 |
included. For example, `sort_copy` is not included because the cost
|
| 131 |
of sorting is much more significant, and users might as well do
|
| 132 |
`copy` followed by `sort`.
|
| 133 |
|
| 134 |
[^2]: `copy_backward` should be used instead of copy when `last` is in
|
| 135 |
-
the range \[`result -
|
| 136 |
|
| 137 |
-
[^3]: `move_backward` should be used instead of move when last is in
|
| 138 |
-
range \[`result -
|
| 139 |
|
| 140 |
[^4]: The use of fully closed ranges is intentional.
|
| 141 |
|
| 142 |
-
[^5]: This behavior intentionally differs from `max_element
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
## C library algorithms <a id="alg.c.library">[[alg.c.library]]</a>
|
| 2 |
|
| 3 |
+
[*Note 1*: The header `<cstdlib>` declares the functions described in
|
| 4 |
+
this subclause. — *end note*]
|
| 5 |
|
| 6 |
``` cpp
|
| 7 |
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
| 8 |
c-compare-pred* compar);
|
| 9 |
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
|
|
|
| 13 |
```
|
| 14 |
|
| 15 |
*Effects:* These functions have the semantics specified in the C
|
| 16 |
standard library.
|
| 17 |
|
| 18 |
+
*Preconditions:* The objects in the array pointed to by `base` are of
|
| 19 |
+
trivial type.
|
| 20 |
|
| 21 |
+
*Throws:* Any exception thrown by `compar`
|
| 22 |
+
[[res.on.exception.handling]].
|
| 23 |
|
| 24 |
ISO C 7.22.5.
|
| 25 |
|
| 26 |
<!-- Link reference definitions -->
|
| 27 |
+
[accumulate]: #accumulate
|
| 28 |
+
[adjacent.difference]: #adjacent.difference
|
| 29 |
[alg.adjacent.find]: #alg.adjacent.find
|
| 30 |
+
[alg.all.of]: #alg.all.of
|
| 31 |
+
[alg.any.of]: #alg.any.of
|
| 32 |
[alg.binary.search]: #alg.binary.search
|
| 33 |
[alg.c.library]: #alg.c.library
|
| 34 |
[alg.clamp]: #alg.clamp
|
| 35 |
[alg.copy]: #alg.copy
|
| 36 |
[alg.count]: #alg.count
|
|
|
|
| 40 |
[alg.find.end]: #alg.find.end
|
| 41 |
[alg.find.first.of]: #alg.find.first.of
|
| 42 |
[alg.foreach]: #alg.foreach
|
| 43 |
[alg.generate]: #alg.generate
|
| 44 |
[alg.heap.operations]: #alg.heap.operations
|
| 45 |
+
[alg.is.permutation]: #alg.is.permutation
|
| 46 |
[alg.lex.comparison]: #alg.lex.comparison
|
| 47 |
[alg.merge]: #alg.merge
|
| 48 |
[alg.min.max]: #alg.min.max
|
| 49 |
[alg.modifying.operations]: #alg.modifying.operations
|
| 50 |
[alg.move]: #alg.move
|
| 51 |
+
[alg.none.of]: #alg.none.of
|
| 52 |
[alg.nonmodifying]: #alg.nonmodifying
|
| 53 |
[alg.nth.element]: #alg.nth.element
|
| 54 |
[alg.partitions]: #alg.partitions
|
| 55 |
[alg.permutation.generators]: #alg.permutation.generators
|
| 56 |
[alg.random.sample]: #alg.random.sample
|
|
|
|
| 59 |
[alg.replace]: #alg.replace
|
| 60 |
[alg.reverse]: #alg.reverse
|
| 61 |
[alg.rotate]: #alg.rotate
|
| 62 |
[alg.search]: #alg.search
|
| 63 |
[alg.set.operations]: #alg.set.operations
|
| 64 |
+
[alg.shift]: #alg.shift
|
| 65 |
[alg.sort]: #alg.sort
|
| 66 |
[alg.sorting]: #alg.sorting
|
| 67 |
[alg.swap]: #alg.swap
|
| 68 |
+
[alg.three.way]: #alg.three.way
|
| 69 |
[alg.transform]: #alg.transform
|
| 70 |
[alg.unique]: #alg.unique
|
| 71 |
[algorithm.stable]: library.md#algorithm.stable
|
| 72 |
[algorithm.syn]: #algorithm.syn
|
| 73 |
[algorithms]: #algorithms
|
|
|
|
| 77 |
[algorithms.parallel.exceptions]: #algorithms.parallel.exceptions
|
| 78 |
[algorithms.parallel.exec]: #algorithms.parallel.exec
|
| 79 |
[algorithms.parallel.overloads]: #algorithms.parallel.overloads
|
| 80 |
[algorithms.parallel.user]: #algorithms.parallel.user
|
| 81 |
[algorithms.requirements]: #algorithms.requirements
|
| 82 |
+
[algorithms.results]: #algorithms.results
|
| 83 |
+
[algorithms.summary]: #algorithms.summary
|
| 84 |
+
[basic.compound]: basic.md#basic.compound
|
| 85 |
+
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 86 |
+
[basic.lookup.unqual]: basic.md#basic.lookup.unqual
|
| 87 |
[bidirectional.iterators]: iterators.md#bidirectional.iterators
|
| 88 |
[binary.search]: #binary.search
|
| 89 |
+
[class.conv]: class.md#class.conv
|
| 90 |
[containers]: containers.md#containers
|
| 91 |
+
[conv]: expr.md#conv
|
| 92 |
+
[conv.integral]: expr.md#conv.integral
|
| 93 |
+
[cpp17.copyassignable]: #cpp17.copyassignable
|
| 94 |
+
[cpp17.copyconstructible]: #cpp17.copyconstructible
|
| 95 |
+
[cpp17.lessthancomparable]: #cpp17.lessthancomparable
|
| 96 |
+
[cpp17.moveassignable]: #cpp17.moveassignable
|
| 97 |
+
[cpp17.moveconstructible]: #cpp17.moveconstructible
|
| 98 |
[equal.range]: #equal.range
|
| 99 |
+
[exclusive.scan]: #exclusive.scan
|
| 100 |
[execpol]: utilities.md#execpol
|
| 101 |
+
[expr.call]: expr.md#expr.call
|
| 102 |
+
[expr.new]: expr.md#expr.new
|
| 103 |
[forward.iterators]: iterators.md#forward.iterators
|
| 104 |
[function.objects]: utilities.md#function.objects
|
| 105 |
[includes]: #includes
|
| 106 |
+
[inclusive.scan]: #inclusive.scan
|
| 107 |
+
[inner.product]: #inner.product
|
| 108 |
[input.iterators]: iterators.md#input.iterators
|
| 109 |
+
[intro.execution]: basic.md#intro.execution
|
| 110 |
+
[intro.object]: basic.md#intro.object
|
| 111 |
+
[intro.progress]: basic.md#intro.progress
|
| 112 |
[is.heap]: #is.heap
|
| 113 |
[is.sorted]: #is.sorted
|
| 114 |
+
[iterator.concept.forward]: iterators.md#iterator.concept.forward
|
| 115 |
+
[iterator.concept.input]: iterators.md#iterator.concept.input
|
| 116 |
+
[iterator.concept.sentinel]: iterators.md#iterator.concept.sentinel
|
| 117 |
+
[iterator.concept.sizedsentinel]: iterators.md#iterator.concept.sizedsentinel
|
| 118 |
[iterator.requirements]: iterators.md#iterator.requirements
|
| 119 |
[iterator.requirements.general]: iterators.md#iterator.requirements.general
|
| 120 |
[lower.bound]: #lower.bound
|
| 121 |
[make.heap]: #make.heap
|
| 122 |
[mismatch]: #mismatch
|
| 123 |
[multiset]: containers.md#multiset
|
| 124 |
+
[numeric.iota]: #numeric.iota
|
| 125 |
+
[numeric.ops]: #numeric.ops
|
| 126 |
+
[numeric.ops.gcd]: #numeric.ops.gcd
|
| 127 |
+
[numeric.ops.lcm]: #numeric.ops.lcm
|
| 128 |
+
[numeric.ops.midpoint]: #numeric.ops.midpoint
|
| 129 |
+
[numeric.ops.overview]: #numeric.ops.overview
|
| 130 |
+
[numerics.defns]: #numerics.defns
|
| 131 |
[output.iterators]: iterators.md#output.iterators
|
| 132 |
[partial.sort]: #partial.sort
|
| 133 |
[partial.sort.copy]: #partial.sort.copy
|
| 134 |
+
[partial.sum]: #partial.sum
|
| 135 |
[pop.heap]: #pop.heap
|
| 136 |
[push.heap]: #push.heap
|
| 137 |
[rand.req.urng]: numerics.md#rand.req.urng
|
| 138 |
[random.access.iterators]: iterators.md#random.access.iterators
|
| 139 |
+
[range.range]: ranges.md#range.range
|
| 140 |
+
[reduce]: #reduce
|
| 141 |
[refwrap]: utilities.md#refwrap
|
| 142 |
[res.on.exception.handling]: library.md#res.on.exception.handling
|
| 143 |
[set.difference]: #set.difference
|
| 144 |
[set.intersection]: #set.intersection
|
| 145 |
[set.symmetric.difference]: #set.symmetric.difference
|
| 146 |
[set.union]: #set.union
|
| 147 |
[sort]: #sort
|
| 148 |
[sort.heap]: #sort.heap
|
| 149 |
+
[special.mem.concepts]: #special.mem.concepts
|
| 150 |
+
[specialized.algorithms]: #specialized.algorithms
|
| 151 |
+
[specialized.construct]: #specialized.construct
|
| 152 |
+
[specialized.destroy]: #specialized.destroy
|
| 153 |
[stable.sort]: #stable.sort
|
| 154 |
[swappable.requirements]: library.md#swappable.requirements
|
| 155 |
+
[temp.func.order]: temp.md#temp.func.order
|
| 156 |
+
[thread.jthread.class]: thread.md#thread.jthread.class
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
[thread.thread.class]: thread.md#thread.thread.class
|
| 158 |
+
[transform.exclusive.scan]: #transform.exclusive.scan
|
| 159 |
+
[transform.inclusive.scan]: #transform.inclusive.scan
|
| 160 |
+
[transform.reduce]: #transform.reduce
|
| 161 |
+
[uninitialized.construct.default]: #uninitialized.construct.default
|
| 162 |
+
[uninitialized.construct.value]: #uninitialized.construct.value
|
| 163 |
+
[uninitialized.copy]: #uninitialized.copy
|
| 164 |
+
[uninitialized.fill]: #uninitialized.fill
|
| 165 |
+
[uninitialized.move]: #uninitialized.move
|
| 166 |
[upper.bound]: #upper.bound
|
| 167 |
|
| 168 |
[^1]: The decision whether to include a copying version was usually
|
| 169 |
based on complexity considerations. When the cost of doing the
|
| 170 |
operation dominates the cost of copy, the copying version is not
|
| 171 |
included. For example, `sort_copy` is not included because the cost
|
| 172 |
of sorting is much more significant, and users might as well do
|
| 173 |
`copy` followed by `sort`.
|
| 174 |
|
| 175 |
[^2]: `copy_backward` should be used instead of copy when `last` is in
|
| 176 |
+
the range \[`result - `N, `result`).
|
| 177 |
|
| 178 |
+
[^3]: `move_backward` should be used instead of move when `last` is in
|
| 179 |
+
the range \[`result - `N, `result`).
|
| 180 |
|
| 181 |
[^4]: The use of fully closed ranges is intentional.
|
| 182 |
|
| 183 |
+
[^5]: This behavior intentionally differs from `max_element`.
|
| 184 |
+
|
| 185 |
+
[^6]: The use of fully closed ranges is intentional.
|
| 186 |
+
|
| 187 |
+
[^7]: `accumulate` is similar to the APL reduction operator and Common
|
| 188 |
+
Lisp reduce function, but it avoids the difficulty of defining the
|
| 189 |
+
result of reduction on an empty sequence by always requiring an
|
| 190 |
+
initial value.
|
| 191 |
+
|
| 192 |
+
[^8]: The use of fully closed ranges is intentional.
|
| 193 |
+
|
| 194 |
+
[^9]: The use of fully closed ranges is intentional.
|
| 195 |
+
|
| 196 |
+
[^10]: The use of fully closed ranges is intentional.
|