00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef ABSL_ALGORITHM_CONTAINER_H_
00041 #define ABSL_ALGORITHM_CONTAINER_H_
00042
00043 #include <algorithm>
00044 #include <cassert>
00045 #include <iterator>
00046 #include <numeric>
00047 #include <type_traits>
00048 #include <unordered_map>
00049 #include <unordered_set>
00050 #include <utility>
00051 #include <vector>
00052
00053 #include "absl/algorithm/algorithm.h"
00054 #include "absl/base/macros.h"
00055 #include "absl/meta/type_traits.h"
00056
00057 namespace absl {
00058 namespace container_algorithm_internal {
00059
00060
00061
00062
00063 using std::begin;
00064 using std::end;
00065
00066
00067
00068
00069 template <typename C>
00070 using ContainerIter = decltype(begin(std::declval<C&>()));
00071
00072
00073
00074 template <typename C1, typename C2>
00075 using ContainerIterPairType =
00076 decltype(std::make_pair(ContainerIter<C1>(), ContainerIter<C2>()));
00077
00078 template <typename C>
00079 using ContainerDifferenceType =
00080 decltype(std::distance(std::declval<ContainerIter<C>>(),
00081 std::declval<ContainerIter<C>>()));
00082
00083 template <typename C>
00084 using ContainerPointerType =
00085 typename std::iterator_traits<ContainerIter<C>>::pointer;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 template <typename C>
00099 ContainerIter<C> c_begin(C& c) { return begin(c); }
00100
00101 template <typename C>
00102 ContainerIter<C> c_end(C& c) { return end(c); }
00103
00104 template <typename T>
00105 struct IsUnorderedContainer : std::false_type {};
00106
00107 template <class Key, class T, class Hash, class KeyEqual, class Allocator>
00108 struct IsUnorderedContainer<
00109 std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type {};
00110
00111 template <class Key, class Hash, class KeyEqual, class Allocator>
00112 struct IsUnorderedContainer<std::unordered_set<Key, Hash, KeyEqual, Allocator>>
00113 : std::true_type {};
00114
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 template <typename C, typename EqualityComparable>
00128 bool c_linear_search(const C& c, EqualityComparable&& value) {
00129 return linear_search(container_algorithm_internal::c_begin(c),
00130 container_algorithm_internal::c_end(c),
00131 std::forward<EqualityComparable>(value));
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 template <typename C>
00143 container_algorithm_internal::ContainerDifferenceType<const C> c_distance(
00144 const C& c) {
00145 return std::distance(container_algorithm_internal::c_begin(c),
00146 container_algorithm_internal::c_end(c));
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 template <typename C, typename Pred>
00158 bool c_all_of(const C& c, Pred&& pred) {
00159 return std::all_of(container_algorithm_internal::c_begin(c),
00160 container_algorithm_internal::c_end(c),
00161 std::forward<Pred>(pred));
00162 }
00163
00164
00165
00166
00167
00168 template <typename C, typename Pred>
00169 bool c_any_of(const C& c, Pred&& pred) {
00170 return std::any_of(container_algorithm_internal::c_begin(c),
00171 container_algorithm_internal::c_end(c),
00172 std::forward<Pred>(pred));
00173 }
00174
00175
00176
00177
00178
00179 template <typename C, typename Pred>
00180 bool c_none_of(const C& c, Pred&& pred) {
00181 return std::none_of(container_algorithm_internal::c_begin(c),
00182 container_algorithm_internal::c_end(c),
00183 std::forward<Pred>(pred));
00184 }
00185
00186
00187
00188
00189
00190 template <typename C, typename Function>
00191 decay_t<Function> c_for_each(C&& c, Function&& f) {
00192 return std::for_each(container_algorithm_internal::c_begin(c),
00193 container_algorithm_internal::c_end(c),
00194 std::forward<Function>(f));
00195 }
00196
00197
00198
00199
00200
00201 template <typename C, typename T>
00202 container_algorithm_internal::ContainerIter<C> c_find(C& c, T&& value) {
00203 return std::find(container_algorithm_internal::c_begin(c),
00204 container_algorithm_internal::c_end(c),
00205 std::forward<T>(value));
00206 }
00207
00208
00209
00210
00211
00212 template <typename C, typename Pred>
00213 container_algorithm_internal::ContainerIter<C> c_find_if(C& c, Pred&& pred) {
00214 return std::find_if(container_algorithm_internal::c_begin(c),
00215 container_algorithm_internal::c_end(c),
00216 std::forward<Pred>(pred));
00217 }
00218
00219
00220
00221
00222
00223 template <typename C, typename Pred>
00224 container_algorithm_internal::ContainerIter<C> c_find_if_not(C& c,
00225 Pred&& pred) {
00226 return std::find_if_not(container_algorithm_internal::c_begin(c),
00227 container_algorithm_internal::c_end(c),
00228 std::forward<Pred>(pred));
00229 }
00230
00231
00232
00233
00234
00235 template <typename Sequence1, typename Sequence2>
00236 container_algorithm_internal::ContainerIter<Sequence1> c_find_end(
00237 Sequence1& sequence, Sequence2& subsequence) {
00238 return std::find_end(container_algorithm_internal::c_begin(sequence),
00239 container_algorithm_internal::c_end(sequence),
00240 container_algorithm_internal::c_begin(subsequence),
00241 container_algorithm_internal::c_end(subsequence));
00242 }
00243
00244
00245
00246 template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
00247 container_algorithm_internal::ContainerIter<Sequence1> c_find_end(
00248 Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
00249 return std::find_end(container_algorithm_internal::c_begin(sequence),
00250 container_algorithm_internal::c_end(sequence),
00251 container_algorithm_internal::c_begin(subsequence),
00252 container_algorithm_internal::c_end(subsequence),
00253 std::forward<BinaryPredicate>(pred));
00254 }
00255
00256
00257
00258
00259
00260 template <typename C1, typename C2>
00261 container_algorithm_internal::ContainerIter<C1> c_find_first_of(C1& container,
00262 C2& options) {
00263 return std::find_first_of(container_algorithm_internal::c_begin(container),
00264 container_algorithm_internal::c_end(container),
00265 container_algorithm_internal::c_begin(options),
00266 container_algorithm_internal::c_end(options));
00267 }
00268
00269
00270
00271 template <typename C1, typename C2, typename BinaryPredicate>
00272 container_algorithm_internal::ContainerIter<C1> c_find_first_of(
00273 C1& container, C2& options, BinaryPredicate&& pred) {
00274 return std::find_first_of(container_algorithm_internal::c_begin(container),
00275 container_algorithm_internal::c_end(container),
00276 container_algorithm_internal::c_begin(options),
00277 container_algorithm_internal::c_end(options),
00278 std::forward<BinaryPredicate>(pred));
00279 }
00280
00281
00282
00283
00284
00285 template <typename Sequence>
00286 container_algorithm_internal::ContainerIter<Sequence> c_adjacent_find(
00287 Sequence& sequence) {
00288 return std::adjacent_find(container_algorithm_internal::c_begin(sequence),
00289 container_algorithm_internal::c_end(sequence));
00290 }
00291
00292
00293
00294 template <typename Sequence, typename BinaryPredicate>
00295 container_algorithm_internal::ContainerIter<Sequence> c_adjacent_find(
00296 Sequence& sequence, BinaryPredicate&& pred) {
00297 return std::adjacent_find(container_algorithm_internal::c_begin(sequence),
00298 container_algorithm_internal::c_end(sequence),
00299 std::forward<BinaryPredicate>(pred));
00300 }
00301
00302
00303
00304
00305
00306 template <typename C, typename T>
00307 container_algorithm_internal::ContainerDifferenceType<const C> c_count(
00308 const C& c, T&& value) {
00309 return std::count(container_algorithm_internal::c_begin(c),
00310 container_algorithm_internal::c_end(c),
00311 std::forward<T>(value));
00312 }
00313
00314
00315
00316
00317
00318 template <typename C, typename Pred>
00319 container_algorithm_internal::ContainerDifferenceType<const C> c_count_if(
00320 const C& c, Pred&& pred) {
00321 return std::count_if(container_algorithm_internal::c_begin(c),
00322 container_algorithm_internal::c_end(c),
00323 std::forward<Pred>(pred));
00324 }
00325
00326
00327
00328
00329
00330 template <typename C1, typename C2>
00331 container_algorithm_internal::ContainerIterPairType<C1, C2>
00332 c_mismatch(C1& c1, C2& c2) {
00333 return std::mismatch(container_algorithm_internal::c_begin(c1),
00334 container_algorithm_internal::c_end(c1),
00335 container_algorithm_internal::c_begin(c2));
00336 }
00337
00338
00339
00340 template <typename C1, typename C2, typename BinaryPredicate>
00341 container_algorithm_internal::ContainerIterPairType<C1, C2>
00342 c_mismatch(C1& c1, C2& c2, BinaryPredicate&& pred) {
00343 return std::mismatch(container_algorithm_internal::c_begin(c1),
00344 container_algorithm_internal::c_end(c1),
00345 container_algorithm_internal::c_begin(c2),
00346 std::forward<BinaryPredicate>(pred));
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366 template <typename C1, typename C2>
00367 bool c_equal(const C1& c1, const C2& c2) {
00368 return ((c1.size() == c2.size()) &&
00369 std::equal(container_algorithm_internal::c_begin(c1),
00370 container_algorithm_internal::c_end(c1),
00371 container_algorithm_internal::c_begin(c2)));
00372 }
00373
00374
00375
00376 template <typename C1, typename C2, typename BinaryPredicate>
00377 bool c_equal(const C1& c1, const C2& c2, BinaryPredicate&& pred) {
00378 return ((c1.size() == c2.size()) &&
00379 std::equal(container_algorithm_internal::c_begin(c1),
00380 container_algorithm_internal::c_end(c1),
00381 container_algorithm_internal::c_begin(c2),
00382 std::forward<BinaryPredicate>(pred)));
00383 }
00384
00385
00386
00387
00388
00389 template <typename C1, typename C2>
00390 bool c_is_permutation(const C1& c1, const C2& c2) {
00391 using std::begin;
00392 using std::end;
00393 return c1.size() == c2.size() &&
00394 std::is_permutation(begin(c1), end(c1), begin(c2));
00395 }
00396
00397
00398
00399 template <typename C1, typename C2, typename BinaryPredicate>
00400 bool c_is_permutation(const C1& c1, const C2& c2, BinaryPredicate&& pred) {
00401 using std::begin;
00402 using std::end;
00403 return c1.size() == c2.size() &&
00404 std::is_permutation(begin(c1), end(c1), begin(c2),
00405 std::forward<BinaryPredicate>(pred));
00406 }
00407
00408
00409
00410
00411
00412 template <typename Sequence1, typename Sequence2>
00413 container_algorithm_internal::ContainerIter<Sequence1> c_search(
00414 Sequence1& sequence, Sequence2& subsequence) {
00415 return std::search(container_algorithm_internal::c_begin(sequence),
00416 container_algorithm_internal::c_end(sequence),
00417 container_algorithm_internal::c_begin(subsequence),
00418 container_algorithm_internal::c_end(subsequence));
00419 }
00420
00421
00422
00423 template <typename Sequence1, typename Sequence2, typename BinaryPredicate>
00424 container_algorithm_internal::ContainerIter<Sequence1> c_search(
00425 Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
00426 return std::search(container_algorithm_internal::c_begin(sequence),
00427 container_algorithm_internal::c_end(sequence),
00428 container_algorithm_internal::c_begin(subsequence),
00429 container_algorithm_internal::c_end(subsequence),
00430 std::forward<BinaryPredicate>(pred));
00431 }
00432
00433
00434
00435
00436
00437 template <typename Sequence, typename Size, typename T>
00438 container_algorithm_internal::ContainerIter<Sequence> c_search_n(
00439 Sequence& sequence, Size count, T&& value) {
00440 return std::search_n(container_algorithm_internal::c_begin(sequence),
00441 container_algorithm_internal::c_end(sequence), count,
00442 std::forward<T>(value));
00443 }
00444
00445
00446
00447 template <typename Sequence, typename Size, typename T,
00448 typename BinaryPredicate>
00449 container_algorithm_internal::ContainerIter<Sequence> c_search_n(
00450 Sequence& sequence, Size count, T&& value, BinaryPredicate&& pred) {
00451 return std::search_n(container_algorithm_internal::c_begin(sequence),
00452 container_algorithm_internal::c_end(sequence), count,
00453 std::forward<T>(value),
00454 std::forward<BinaryPredicate>(pred));
00455 }
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465 template <typename InputSequence, typename OutputIterator>
00466 OutputIterator c_copy(const InputSequence& input, OutputIterator output) {
00467 return std::copy(container_algorithm_internal::c_begin(input),
00468 container_algorithm_internal::c_end(input), output);
00469 }
00470
00471
00472
00473
00474
00475 template <typename C, typename Size, typename OutputIterator>
00476 OutputIterator c_copy_n(const C& input, Size n, OutputIterator output) {
00477 return std::copy_n(container_algorithm_internal::c_begin(input), n, output);
00478 }
00479
00480
00481
00482
00483
00484 template <typename InputSequence, typename OutputIterator, typename Pred>
00485 OutputIterator c_copy_if(const InputSequence& input, OutputIterator output,
00486 Pred&& pred) {
00487 return std::copy_if(container_algorithm_internal::c_begin(input),
00488 container_algorithm_internal::c_end(input), output,
00489 std::forward<Pred>(pred));
00490 }
00491
00492
00493
00494
00495
00496 template <typename C, typename BidirectionalIterator>
00497 BidirectionalIterator c_copy_backward(const C& src,
00498 BidirectionalIterator dest) {
00499 return std::copy_backward(container_algorithm_internal::c_begin(src),
00500 container_algorithm_internal::c_end(src), dest);
00501 }
00502
00503
00504
00505
00506
00507 template <typename C, typename OutputIterator>
00508 OutputIterator c_move(C&& src, OutputIterator dest) {
00509 return std::move(container_algorithm_internal::c_begin(src),
00510 container_algorithm_internal::c_end(src), dest);
00511 }
00512
00513
00514
00515
00516
00517 template <typename C1, typename C2>
00518 container_algorithm_internal::ContainerIter<C2> c_swap_ranges(C1& c1, C2& c2) {
00519 return std::swap_ranges(container_algorithm_internal::c_begin(c1),
00520 container_algorithm_internal::c_end(c1),
00521 container_algorithm_internal::c_begin(c2));
00522 }
00523
00524
00525
00526
00527
00528
00529
00530 template <typename InputSequence, typename OutputIterator, typename UnaryOp>
00531 OutputIterator c_transform(const InputSequence& input, OutputIterator output,
00532 UnaryOp&& unary_op) {
00533 return std::transform(container_algorithm_internal::c_begin(input),
00534 container_algorithm_internal::c_end(input), output,
00535 std::forward<UnaryOp>(unary_op));
00536 }
00537
00538
00539
00540 template <typename InputSequence1, typename InputSequence2,
00541 typename OutputIterator, typename BinaryOp>
00542 OutputIterator c_transform(const InputSequence1& input1,
00543 const InputSequence2& input2, OutputIterator output,
00544 BinaryOp&& binary_op) {
00545 return std::transform(container_algorithm_internal::c_begin(input1),
00546 container_algorithm_internal::c_end(input1),
00547 container_algorithm_internal::c_begin(input2), output,
00548 std::forward<BinaryOp>(binary_op));
00549 }
00550
00551
00552
00553
00554
00555
00556 template <typename Sequence, typename T>
00557 void c_replace(Sequence& sequence, const T& old_value, const T& new_value) {
00558 std::replace(container_algorithm_internal::c_begin(sequence),
00559 container_algorithm_internal::c_end(sequence), old_value,
00560 new_value);
00561 }
00562
00563
00564
00565
00566
00567
00568 template <typename C, typename Pred, typename T>
00569 void c_replace_if(C& c, Pred&& pred, T&& new_value) {
00570 std::replace_if(container_algorithm_internal::c_begin(c),
00571 container_algorithm_internal::c_end(c),
00572 std::forward<Pred>(pred), std::forward<T>(new_value));
00573 }
00574
00575
00576
00577
00578
00579
00580 template <typename C, typename OutputIterator, typename T>
00581 OutputIterator c_replace_copy(const C& c, OutputIterator result, T&& old_value,
00582 T&& new_value) {
00583 return std::replace_copy(container_algorithm_internal::c_begin(c),
00584 container_algorithm_internal::c_end(c), result,
00585 std::forward<T>(old_value),
00586 std::forward<T>(new_value));
00587 }
00588
00589
00590
00591
00592
00593
00594 template <typename C, typename OutputIterator, typename Pred, typename T>
00595 OutputIterator c_replace_copy_if(const C& c, OutputIterator result, Pred&& pred,
00596 T&& new_value) {
00597 return std::replace_copy_if(container_algorithm_internal::c_begin(c),
00598 container_algorithm_internal::c_end(c), result,
00599 std::forward<Pred>(pred),
00600 std::forward<T>(new_value));
00601 }
00602
00603
00604
00605
00606
00607 template <typename C, typename T>
00608 void c_fill(C& c, T&& value) {
00609 std::fill(container_algorithm_internal::c_begin(c),
00610 container_algorithm_internal::c_end(c), std::forward<T>(value));
00611 }
00612
00613
00614
00615
00616
00617 template <typename C, typename Size, typename T>
00618 void c_fill_n(C& c, Size n, T&& value) {
00619 std::fill_n(container_algorithm_internal::c_begin(c), n,
00620 std::forward<T>(value));
00621 }
00622
00623
00624
00625
00626
00627 template <typename C, typename Generator>
00628 void c_generate(C& c, Generator&& gen) {
00629 std::generate(container_algorithm_internal::c_begin(c),
00630 container_algorithm_internal::c_end(c),
00631 std::forward<Generator>(gen));
00632 }
00633
00634
00635
00636
00637
00638
00639 template <typename C, typename Size, typename Generator>
00640 container_algorithm_internal::ContainerIter<C> c_generate_n(C& c, Size n,
00641 Generator&& gen) {
00642 return std::generate_n(container_algorithm_internal::c_begin(c), n,
00643 std::forward<Generator>(gen));
00644 }
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656 template <typename C, typename OutputIterator, typename T>
00657 OutputIterator c_remove_copy(const C& c, OutputIterator result, T&& value) {
00658 return std::remove_copy(container_algorithm_internal::c_begin(c),
00659 container_algorithm_internal::c_end(c), result,
00660 std::forward<T>(value));
00661 }
00662
00663
00664
00665
00666
00667
00668 template <typename C, typename OutputIterator, typename Pred>
00669 OutputIterator c_remove_copy_if(const C& c, OutputIterator result,
00670 Pred&& pred) {
00671 return std::remove_copy_if(container_algorithm_internal::c_begin(c),
00672 container_algorithm_internal::c_end(c), result,
00673 std::forward<Pred>(pred));
00674 }
00675
00676
00677
00678
00679
00680
00681 template <typename C, typename OutputIterator>
00682 OutputIterator c_unique_copy(const C& c, OutputIterator result) {
00683 return std::unique_copy(container_algorithm_internal::c_begin(c),
00684 container_algorithm_internal::c_end(c), result);
00685 }
00686
00687
00688
00689 template <typename C, typename OutputIterator, typename BinaryPredicate>
00690 OutputIterator c_unique_copy(const C& c, OutputIterator result,
00691 BinaryPredicate&& pred) {
00692 return std::unique_copy(container_algorithm_internal::c_begin(c),
00693 container_algorithm_internal::c_end(c), result,
00694 std::forward<BinaryPredicate>(pred));
00695 }
00696
00697
00698
00699
00700
00701 template <typename Sequence>
00702 void c_reverse(Sequence& sequence) {
00703 std::reverse(container_algorithm_internal::c_begin(sequence),
00704 container_algorithm_internal::c_end(sequence));
00705 }
00706
00707
00708
00709
00710
00711 template <typename C, typename OutputIterator>
00712 OutputIterator c_reverse_copy(const C& sequence, OutputIterator result) {
00713 return std::reverse_copy(container_algorithm_internal::c_begin(sequence),
00714 container_algorithm_internal::c_end(sequence),
00715 result);
00716 }
00717
00718
00719
00720
00721
00722
00723 template <typename C,
00724 typename Iterator = container_algorithm_internal::ContainerIter<C>>
00725 Iterator c_rotate(C& sequence, Iterator middle) {
00726 return absl::rotate(container_algorithm_internal::c_begin(sequence), middle,
00727 container_algorithm_internal::c_end(sequence));
00728 }
00729
00730
00731
00732
00733
00734
00735 template <typename C, typename OutputIterator>
00736 OutputIterator c_rotate_copy(
00737 const C& sequence,
00738 container_algorithm_internal::ContainerIter<const C> middle,
00739 OutputIterator result) {
00740 return std::rotate_copy(container_algorithm_internal::c_begin(sequence),
00741 middle, container_algorithm_internal::c_end(sequence),
00742 result);
00743 }
00744
00745
00746
00747
00748
00749
00750 template <typename RandomAccessContainer, typename UniformRandomBitGenerator>
00751 void c_shuffle(RandomAccessContainer& c, UniformRandomBitGenerator&& gen) {
00752 std::shuffle(container_algorithm_internal::c_begin(c),
00753 container_algorithm_internal::c_end(c),
00754 std::forward<UniformRandomBitGenerator>(gen));
00755 }
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766 template <typename C, typename Pred>
00767 bool c_is_partitioned(const C& c, Pred&& pred) {
00768 return std::is_partitioned(container_algorithm_internal::c_begin(c),
00769 container_algorithm_internal::c_end(c),
00770 std::forward<Pred>(pred));
00771 }
00772
00773
00774
00775
00776
00777
00778
00779 template <typename C, typename Pred>
00780 container_algorithm_internal::ContainerIter<C> c_partition(C& c, Pred&& pred) {
00781 return std::partition(container_algorithm_internal::c_begin(c),
00782 container_algorithm_internal::c_end(c),
00783 std::forward<Pred>(pred));
00784 }
00785
00786
00787
00788
00789
00790
00791
00792
00793 template <typename C, typename Pred>
00794 container_algorithm_internal::ContainerIter<C> c_stable_partition(C& c,
00795 Pred&& pred) {
00796 return std::stable_partition(container_algorithm_internal::c_begin(c),
00797 container_algorithm_internal::c_end(c),
00798 std::forward<Pred>(pred));
00799 }
00800
00801
00802
00803
00804
00805
00806
00807 template <typename C, typename OutputIterator1, typename OutputIterator2,
00808 typename Pred>
00809 std::pair<OutputIterator1, OutputIterator2> c_partition_copy(
00810 const C& c, OutputIterator1 out_true, OutputIterator2 out_false,
00811 Pred&& pred) {
00812 return std::partition_copy(container_algorithm_internal::c_begin(c),
00813 container_algorithm_internal::c_end(c), out_true,
00814 out_false, std::forward<Pred>(pred));
00815 }
00816
00817
00818
00819
00820
00821
00822 template <typename C, typename Pred>
00823 container_algorithm_internal::ContainerIter<C> c_partition_point(C& c,
00824 Pred&& pred) {
00825 return std::partition_point(container_algorithm_internal::c_begin(c),
00826 container_algorithm_internal::c_end(c),
00827 std::forward<Pred>(pred));
00828 }
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838 template <typename C>
00839 void c_sort(C& c) {
00840 std::sort(container_algorithm_internal::c_begin(c),
00841 container_algorithm_internal::c_end(c));
00842 }
00843
00844
00845
00846 template <typename C, typename Compare>
00847 void c_sort(C& c, Compare&& comp) {
00848 std::sort(container_algorithm_internal::c_begin(c),
00849 container_algorithm_internal::c_end(c),
00850 std::forward<Compare>(comp));
00851 }
00852
00853
00854
00855
00856
00857
00858 template <typename C>
00859 void c_stable_sort(C& c) {
00860 std::stable_sort(container_algorithm_internal::c_begin(c),
00861 container_algorithm_internal::c_end(c));
00862 }
00863
00864
00865
00866 template <typename C, typename Compare>
00867 void c_stable_sort(C& c, Compare&& comp) {
00868 std::stable_sort(container_algorithm_internal::c_begin(c),
00869 container_algorithm_internal::c_end(c),
00870 std::forward<Compare>(comp));
00871 }
00872
00873
00874
00875
00876
00877 template <typename C>
00878 bool c_is_sorted(const C& c) {
00879 return std::is_sorted(container_algorithm_internal::c_begin(c),
00880 container_algorithm_internal::c_end(c));
00881 }
00882
00883
00884
00885 template <typename C, typename Compare>
00886 bool c_is_sorted(const C& c, Compare&& comp) {
00887 return std::is_sorted(container_algorithm_internal::c_begin(c),
00888 container_algorithm_internal::c_end(c),
00889 std::forward<Compare>(comp));
00890 }
00891
00892
00893
00894
00895
00896
00897 template <typename RandomAccessContainer>
00898 void c_partial_sort(
00899 RandomAccessContainer& sequence,
00900 container_algorithm_internal::ContainerIter<RandomAccessContainer> middle) {
00901 std::partial_sort(container_algorithm_internal::c_begin(sequence), middle,
00902 container_algorithm_internal::c_end(sequence));
00903 }
00904
00905
00906
00907 template <typename RandomAccessContainer, typename Compare>
00908 void c_partial_sort(
00909 RandomAccessContainer& sequence,
00910 container_algorithm_internal::ContainerIter<RandomAccessContainer> middle,
00911 Compare&& comp) {
00912 std::partial_sort(container_algorithm_internal::c_begin(sequence), middle,
00913 container_algorithm_internal::c_end(sequence),
00914 std::forward<Compare>(comp));
00915 }
00916
00917
00918
00919
00920
00921
00922
00923 template <typename C, typename RandomAccessContainer>
00924 container_algorithm_internal::ContainerIter<RandomAccessContainer>
00925 c_partial_sort_copy(const C& sequence, RandomAccessContainer& result) {
00926 return std::partial_sort_copy(container_algorithm_internal::c_begin(sequence),
00927 container_algorithm_internal::c_end(sequence),
00928 container_algorithm_internal::c_begin(result),
00929 container_algorithm_internal::c_end(result));
00930 }
00931
00932
00933
00934 template <typename C, typename RandomAccessContainer, typename Compare>
00935 container_algorithm_internal::ContainerIter<RandomAccessContainer>
00936 c_partial_sort_copy(const C& sequence, RandomAccessContainer& result,
00937 Compare&& comp) {
00938 return std::partial_sort_copy(container_algorithm_internal::c_begin(sequence),
00939 container_algorithm_internal::c_end(sequence),
00940 container_algorithm_internal::c_begin(result),
00941 container_algorithm_internal::c_end(result),
00942 std::forward<Compare>(comp));
00943 }
00944
00945
00946
00947
00948
00949
00950 template <typename C>
00951 container_algorithm_internal::ContainerIter<C> c_is_sorted_until(C& c) {
00952 return std::is_sorted_until(container_algorithm_internal::c_begin(c),
00953 container_algorithm_internal::c_end(c));
00954 }
00955
00956
00957
00958 template <typename C, typename Compare>
00959 container_algorithm_internal::ContainerIter<C> c_is_sorted_until(
00960 C& c, Compare&& comp) {
00961 return std::is_sorted_until(container_algorithm_internal::c_begin(c),
00962 container_algorithm_internal::c_end(c),
00963 std::forward<Compare>(comp));
00964 }
00965
00966
00967
00968
00969
00970
00971
00972
00973 template <typename RandomAccessContainer>
00974 void c_nth_element(
00975 RandomAccessContainer& sequence,
00976 container_algorithm_internal::ContainerIter<RandomAccessContainer> nth) {
00977 std::nth_element(container_algorithm_internal::c_begin(sequence), nth,
00978 container_algorithm_internal::c_end(sequence));
00979 }
00980
00981
00982
00983 template <typename RandomAccessContainer, typename Compare>
00984 void c_nth_element(
00985 RandomAccessContainer& sequence,
00986 container_algorithm_internal::ContainerIter<RandomAccessContainer> nth,
00987 Compare&& comp) {
00988 std::nth_element(container_algorithm_internal::c_begin(sequence), nth,
00989 container_algorithm_internal::c_end(sequence),
00990 std::forward<Compare>(comp));
00991 }
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002 template <typename Sequence, typename T>
01003 container_algorithm_internal::ContainerIter<Sequence> c_lower_bound(
01004 Sequence& sequence, T&& value) {
01005 return std::lower_bound(container_algorithm_internal::c_begin(sequence),
01006 container_algorithm_internal::c_end(sequence),
01007 std::forward<T>(value));
01008 }
01009
01010
01011
01012 template <typename Sequence, typename T, typename Compare>
01013 container_algorithm_internal::ContainerIter<Sequence> c_lower_bound(
01014 Sequence& sequence, T&& value, Compare&& comp) {
01015 return std::lower_bound(container_algorithm_internal::c_begin(sequence),
01016 container_algorithm_internal::c_end(sequence),
01017 std::forward<T>(value), std::forward<Compare>(comp));
01018 }
01019
01020
01021
01022
01023
01024
01025 template <typename Sequence, typename T>
01026 container_algorithm_internal::ContainerIter<Sequence> c_upper_bound(
01027 Sequence& sequence, T&& value) {
01028 return std::upper_bound(container_algorithm_internal::c_begin(sequence),
01029 container_algorithm_internal::c_end(sequence),
01030 std::forward<T>(value));
01031 }
01032
01033
01034
01035 template <typename Sequence, typename T, typename Compare>
01036 container_algorithm_internal::ContainerIter<Sequence> c_upper_bound(
01037 Sequence& sequence, T&& value, Compare&& comp) {
01038 return std::upper_bound(container_algorithm_internal::c_begin(sequence),
01039 container_algorithm_internal::c_end(sequence),
01040 std::forward<T>(value), std::forward<Compare>(comp));
01041 }
01042
01043
01044
01045
01046
01047
01048 template <typename Sequence, typename T>
01049 container_algorithm_internal::ContainerIterPairType<Sequence, Sequence>
01050 c_equal_range(Sequence& sequence, T&& value) {
01051 return std::equal_range(container_algorithm_internal::c_begin(sequence),
01052 container_algorithm_internal::c_end(sequence),
01053 std::forward<T>(value));
01054 }
01055
01056
01057
01058 template <typename Sequence, typename T, typename Compare>
01059 container_algorithm_internal::ContainerIterPairType<Sequence, Sequence>
01060 c_equal_range(Sequence& sequence, T&& value, Compare&& comp) {
01061 return std::equal_range(container_algorithm_internal::c_begin(sequence),
01062 container_algorithm_internal::c_end(sequence),
01063 std::forward<T>(value), std::forward<Compare>(comp));
01064 }
01065
01066
01067
01068
01069
01070
01071 template <typename Sequence, typename T>
01072 bool c_binary_search(Sequence&& sequence, T&& value) {
01073 return std::binary_search(container_algorithm_internal::c_begin(sequence),
01074 container_algorithm_internal::c_end(sequence),
01075 std::forward<T>(value));
01076 }
01077
01078
01079
01080 template <typename Sequence, typename T, typename Compare>
01081 bool c_binary_search(Sequence&& sequence, T&& value, Compare&& comp) {
01082 return std::binary_search(container_algorithm_internal::c_begin(sequence),
01083 container_algorithm_internal::c_end(sequence),
01084 std::forward<T>(value),
01085 std::forward<Compare>(comp));
01086 }
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096 template <typename C1, typename C2, typename OutputIterator>
01097 OutputIterator c_merge(const C1& c1, const C2& c2, OutputIterator result) {
01098 return std::merge(container_algorithm_internal::c_begin(c1),
01099 container_algorithm_internal::c_end(c1),
01100 container_algorithm_internal::c_begin(c2),
01101 container_algorithm_internal::c_end(c2), result);
01102 }
01103
01104
01105
01106 template <typename C1, typename C2, typename OutputIterator, typename Compare>
01107 OutputIterator c_merge(const C1& c1, const C2& c2, OutputIterator result,
01108 Compare&& comp) {
01109 return std::merge(container_algorithm_internal::c_begin(c1),
01110 container_algorithm_internal::c_end(c1),
01111 container_algorithm_internal::c_begin(c2),
01112 container_algorithm_internal::c_end(c2), result,
01113 std::forward<Compare>(comp));
01114 }
01115
01116
01117
01118
01119
01120 template <typename C>
01121 void c_inplace_merge(C& c,
01122 container_algorithm_internal::ContainerIter<C> middle) {
01123 std::inplace_merge(container_algorithm_internal::c_begin(c), middle,
01124 container_algorithm_internal::c_end(c));
01125 }
01126
01127
01128
01129 template <typename C, typename Compare>
01130 void c_inplace_merge(C& c,
01131 container_algorithm_internal::ContainerIter<C> middle,
01132 Compare&& comp) {
01133 std::inplace_merge(container_algorithm_internal::c_begin(c), middle,
01134 container_algorithm_internal::c_end(c),
01135 std::forward<Compare>(comp));
01136 }
01137
01138
01139
01140
01141
01142
01143 template <typename C1, typename C2>
01144 bool c_includes(const C1& c1, const C2& c2) {
01145 return std::includes(container_algorithm_internal::c_begin(c1),
01146 container_algorithm_internal::c_end(c1),
01147 container_algorithm_internal::c_begin(c2),
01148 container_algorithm_internal::c_end(c2));
01149 }
01150
01151
01152
01153 template <typename C1, typename C2, typename Compare>
01154 bool c_includes(const C1& c1, const C2& c2, Compare&& comp) {
01155 return std::includes(container_algorithm_internal::c_begin(c1),
01156 container_algorithm_internal::c_end(c1),
01157 container_algorithm_internal::c_begin(c2),
01158 container_algorithm_internal::c_end(c2),
01159 std::forward<Compare>(comp));
01160 }
01161
01162
01163
01164
01165
01166
01167 template <typename C1, typename C2, typename OutputIterator,
01168 typename = typename std::enable_if<
01169 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01170 void>::type,
01171 typename = typename std::enable_if<
01172 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01173 void>::type>
01174 OutputIterator c_set_union(const C1& c1, const C2& c2, OutputIterator output) {
01175 return std::set_union(container_algorithm_internal::c_begin(c1),
01176 container_algorithm_internal::c_end(c1),
01177 container_algorithm_internal::c_begin(c2),
01178 container_algorithm_internal::c_end(c2), output);
01179 }
01180
01181
01182
01183 template <typename C1, typename C2, typename OutputIterator, typename Compare,
01184 typename = typename std::enable_if<
01185 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01186 void>::type,
01187 typename = typename std::enable_if<
01188 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01189 void>::type>
01190 OutputIterator c_set_union(const C1& c1, const C2& c2, OutputIterator output,
01191 Compare&& comp) {
01192 return std::set_union(container_algorithm_internal::c_begin(c1),
01193 container_algorithm_internal::c_end(c1),
01194 container_algorithm_internal::c_begin(c2),
01195 container_algorithm_internal::c_end(c2), output,
01196 std::forward<Compare>(comp));
01197 }
01198
01199
01200
01201
01202
01203 template <typename C1, typename C2, typename OutputIterator,
01204 typename = typename std::enable_if<
01205 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01206 void>::type,
01207 typename = typename std::enable_if<
01208 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01209 void>::type>
01210 OutputIterator c_set_intersection(const C1& c1, const C2& c2,
01211 OutputIterator output) {
01212 return std::set_intersection(container_algorithm_internal::c_begin(c1),
01213 container_algorithm_internal::c_end(c1),
01214 container_algorithm_internal::c_begin(c2),
01215 container_algorithm_internal::c_end(c2), output);
01216 }
01217
01218
01219
01220 template <typename C1, typename C2, typename OutputIterator, typename Compare,
01221 typename = typename std::enable_if<
01222 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01223 void>::type,
01224 typename = typename std::enable_if<
01225 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01226 void>::type>
01227 OutputIterator c_set_intersection(const C1& c1, const C2& c2,
01228 OutputIterator output, Compare&& comp) {
01229 return std::set_intersection(container_algorithm_internal::c_begin(c1),
01230 container_algorithm_internal::c_end(c1),
01231 container_algorithm_internal::c_begin(c2),
01232 container_algorithm_internal::c_end(c2), output,
01233 std::forward<Compare>(comp));
01234 }
01235
01236
01237
01238
01239
01240
01241 template <typename C1, typename C2, typename OutputIterator,
01242 typename = typename std::enable_if<
01243 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01244 void>::type,
01245 typename = typename std::enable_if<
01246 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01247 void>::type>
01248 OutputIterator c_set_difference(const C1& c1, const C2& c2,
01249 OutputIterator output) {
01250 return std::set_difference(container_algorithm_internal::c_begin(c1),
01251 container_algorithm_internal::c_end(c1),
01252 container_algorithm_internal::c_begin(c2),
01253 container_algorithm_internal::c_end(c2), output);
01254 }
01255
01256
01257
01258 template <typename C1, typename C2, typename OutputIterator, typename Compare,
01259 typename = typename std::enable_if<
01260 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01261 void>::type,
01262 typename = typename std::enable_if<
01263 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01264 void>::type>
01265 OutputIterator c_set_difference(const C1& c1, const C2& c2,
01266 OutputIterator output, Compare&& comp) {
01267 return std::set_difference(container_algorithm_internal::c_begin(c1),
01268 container_algorithm_internal::c_end(c1),
01269 container_algorithm_internal::c_begin(c2),
01270 container_algorithm_internal::c_end(c2), output,
01271 std::forward<Compare>(comp));
01272 }
01273
01274
01275
01276
01277
01278
01279 template <typename C1, typename C2, typename OutputIterator,
01280 typename = typename std::enable_if<
01281 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01282 void>::type,
01283 typename = typename std::enable_if<
01284 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01285 void>::type>
01286 OutputIterator c_set_symmetric_difference(const C1& c1, const C2& c2,
01287 OutputIterator output) {
01288 return std::set_symmetric_difference(
01289 container_algorithm_internal::c_begin(c1),
01290 container_algorithm_internal::c_end(c1),
01291 container_algorithm_internal::c_begin(c2),
01292 container_algorithm_internal::c_end(c2), output);
01293 }
01294
01295
01296
01297 template <typename C1, typename C2, typename OutputIterator, typename Compare,
01298 typename = typename std::enable_if<
01299 !container_algorithm_internal::IsUnorderedContainer<C1>::value,
01300 void>::type,
01301 typename = typename std::enable_if<
01302 !container_algorithm_internal::IsUnorderedContainer<C2>::value,
01303 void>::type>
01304 OutputIterator c_set_symmetric_difference(const C1& c1, const C2& c2,
01305 OutputIterator output,
01306 Compare&& comp) {
01307 return std::set_symmetric_difference(
01308 container_algorithm_internal::c_begin(c1),
01309 container_algorithm_internal::c_end(c1),
01310 container_algorithm_internal::c_begin(c2),
01311 container_algorithm_internal::c_end(c2), output,
01312 std::forward<Compare>(comp));
01313 }
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323 template <typename RandomAccessContainer>
01324 void c_push_heap(RandomAccessContainer& sequence) {
01325 std::push_heap(container_algorithm_internal::c_begin(sequence),
01326 container_algorithm_internal::c_end(sequence));
01327 }
01328
01329
01330
01331 template <typename RandomAccessContainer, typename Compare>
01332 void c_push_heap(RandomAccessContainer& sequence, Compare&& comp) {
01333 std::push_heap(container_algorithm_internal::c_begin(sequence),
01334 container_algorithm_internal::c_end(sequence),
01335 std::forward<Compare>(comp));
01336 }
01337
01338
01339
01340
01341
01342 template <typename RandomAccessContainer>
01343 void c_pop_heap(RandomAccessContainer& sequence) {
01344 std::pop_heap(container_algorithm_internal::c_begin(sequence),
01345 container_algorithm_internal::c_end(sequence));
01346 }
01347
01348
01349
01350 template <typename RandomAccessContainer, typename Compare>
01351 void c_pop_heap(RandomAccessContainer& sequence, Compare&& comp) {
01352 std::pop_heap(container_algorithm_internal::c_begin(sequence),
01353 container_algorithm_internal::c_end(sequence),
01354 std::forward<Compare>(comp));
01355 }
01356
01357
01358
01359
01360
01361 template <typename RandomAccessContainer>
01362 void c_make_heap(RandomAccessContainer& sequence) {
01363 std::make_heap(container_algorithm_internal::c_begin(sequence),
01364 container_algorithm_internal::c_end(sequence));
01365 }
01366
01367
01368
01369 template <typename RandomAccessContainer, typename Compare>
01370 void c_make_heap(RandomAccessContainer& sequence, Compare&& comp) {
01371 std::make_heap(container_algorithm_internal::c_begin(sequence),
01372 container_algorithm_internal::c_end(sequence),
01373 std::forward<Compare>(comp));
01374 }
01375
01376
01377
01378
01379
01380 template <typename RandomAccessContainer>
01381 void c_sort_heap(RandomAccessContainer& sequence) {
01382 std::sort_heap(container_algorithm_internal::c_begin(sequence),
01383 container_algorithm_internal::c_end(sequence));
01384 }
01385
01386
01387
01388 template <typename RandomAccessContainer, typename Compare>
01389 void c_sort_heap(RandomAccessContainer& sequence, Compare&& comp) {
01390 std::sort_heap(container_algorithm_internal::c_begin(sequence),
01391 container_algorithm_internal::c_end(sequence),
01392 std::forward<Compare>(comp));
01393 }
01394
01395
01396
01397
01398
01399 template <typename RandomAccessContainer>
01400 bool c_is_heap(const RandomAccessContainer& sequence) {
01401 return std::is_heap(container_algorithm_internal::c_begin(sequence),
01402 container_algorithm_internal::c_end(sequence));
01403 }
01404
01405
01406
01407 template <typename RandomAccessContainer, typename Compare>
01408 bool c_is_heap(const RandomAccessContainer& sequence, Compare&& comp) {
01409 return std::is_heap(container_algorithm_internal::c_begin(sequence),
01410 container_algorithm_internal::c_end(sequence),
01411 std::forward<Compare>(comp));
01412 }
01413
01414
01415
01416
01417
01418 template <typename RandomAccessContainer>
01419 container_algorithm_internal::ContainerIter<RandomAccessContainer>
01420 c_is_heap_until(RandomAccessContainer& sequence) {
01421 return std::is_heap_until(container_algorithm_internal::c_begin(sequence),
01422 container_algorithm_internal::c_end(sequence));
01423 }
01424
01425
01426
01427 template <typename RandomAccessContainer, typename Compare>
01428 container_algorithm_internal::ContainerIter<RandomAccessContainer>
01429 c_is_heap_until(RandomAccessContainer& sequence, Compare&& comp) {
01430 return std::is_heap_until(container_algorithm_internal::c_begin(sequence),
01431 container_algorithm_internal::c_end(sequence),
01432 std::forward<Compare>(comp));
01433 }
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444 template <typename Sequence>
01445 container_algorithm_internal::ContainerIter<Sequence> c_min_element(
01446 Sequence& sequence) {
01447 return std::min_element(container_algorithm_internal::c_begin(sequence),
01448 container_algorithm_internal::c_end(sequence));
01449 }
01450
01451
01452
01453 template <typename Sequence, typename Compare>
01454 container_algorithm_internal::ContainerIter<Sequence> c_min_element(
01455 Sequence& sequence, Compare&& comp) {
01456 return std::min_element(container_algorithm_internal::c_begin(sequence),
01457 container_algorithm_internal::c_end(sequence),
01458 std::forward<Compare>(comp));
01459 }
01460
01461
01462
01463
01464
01465
01466 template <typename Sequence>
01467 container_algorithm_internal::ContainerIter<Sequence> c_max_element(
01468 Sequence& sequence) {
01469 return std::max_element(container_algorithm_internal::c_begin(sequence),
01470 container_algorithm_internal::c_end(sequence));
01471 }
01472
01473
01474
01475 template <typename Sequence, typename Compare>
01476 container_algorithm_internal::ContainerIter<Sequence> c_max_element(
01477 Sequence& sequence, Compare&& comp) {
01478 return std::max_element(container_algorithm_internal::c_begin(sequence),
01479 container_algorithm_internal::c_end(sequence),
01480 std::forward<Compare>(comp));
01481 }
01482
01483
01484
01485
01486
01487
01488
01489 template <typename C>
01490 container_algorithm_internal::ContainerIterPairType<C, C>
01491 c_minmax_element(C& c) {
01492 return std::minmax_element(container_algorithm_internal::c_begin(c),
01493 container_algorithm_internal::c_end(c));
01494 }
01495
01496
01497
01498 template <typename C, typename Compare>
01499 container_algorithm_internal::ContainerIterPairType<C, C>
01500 c_minmax_element(C& c, Compare&& comp) {
01501 return std::minmax_element(container_algorithm_internal::c_begin(c),
01502 container_algorithm_internal::c_end(c),
01503 std::forward<Compare>(comp));
01504 }
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517 template <typename Sequence1, typename Sequence2>
01518 bool c_lexicographical_compare(Sequence1&& sequence1, Sequence2&& sequence2) {
01519 return std::lexicographical_compare(
01520 container_algorithm_internal::c_begin(sequence1),
01521 container_algorithm_internal::c_end(sequence1),
01522 container_algorithm_internal::c_begin(sequence2),
01523 container_algorithm_internal::c_end(sequence2));
01524 }
01525
01526
01527
01528 template <typename Sequence1, typename Sequence2, typename Compare>
01529 bool c_lexicographical_compare(Sequence1&& sequence1, Sequence2&& sequence2,
01530 Compare&& comp) {
01531 return std::lexicographical_compare(
01532 container_algorithm_internal::c_begin(sequence1),
01533 container_algorithm_internal::c_end(sequence1),
01534 container_algorithm_internal::c_begin(sequence2),
01535 container_algorithm_internal::c_end(sequence2),
01536 std::forward<Compare>(comp));
01537 }
01538
01539
01540
01541
01542
01543
01544 template <typename C>
01545 bool c_next_permutation(C& c) {
01546 return std::next_permutation(container_algorithm_internal::c_begin(c),
01547 container_algorithm_internal::c_end(c));
01548 }
01549
01550
01551
01552 template <typename C, typename Compare>
01553 bool c_next_permutation(C& c, Compare&& comp) {
01554 return std::next_permutation(container_algorithm_internal::c_begin(c),
01555 container_algorithm_internal::c_end(c),
01556 std::forward<Compare>(comp));
01557 }
01558
01559
01560
01561
01562
01563
01564 template <typename C>
01565 bool c_prev_permutation(C& c) {
01566 return std::prev_permutation(container_algorithm_internal::c_begin(c),
01567 container_algorithm_internal::c_end(c));
01568 }
01569
01570
01571
01572 template <typename C, typename Compare>
01573 bool c_prev_permutation(C& c, Compare&& comp) {
01574 return std::prev_permutation(container_algorithm_internal::c_begin(c),
01575 container_algorithm_internal::c_end(c),
01576 std::forward<Compare>(comp));
01577 }
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588 template <typename Sequence, typename T>
01589 void c_iota(Sequence& sequence, T&& value) {
01590 std::iota(container_algorithm_internal::c_begin(sequence),
01591 container_algorithm_internal::c_end(sequence),
01592 std::forward<T>(value));
01593 }
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603 template <typename Sequence, typename T>
01604 decay_t<T> c_accumulate(const Sequence& sequence, T&& init) {
01605 return std::accumulate(container_algorithm_internal::c_begin(sequence),
01606 container_algorithm_internal::c_end(sequence),
01607 std::forward<T>(init));
01608 }
01609
01610
01611
01612 template <typename Sequence, typename T, typename BinaryOp>
01613 decay_t<T> c_accumulate(const Sequence& sequence, T&& init,
01614 BinaryOp&& binary_op) {
01615 return std::accumulate(container_algorithm_internal::c_begin(sequence),
01616 container_algorithm_internal::c_end(sequence),
01617 std::forward<T>(init),
01618 std::forward<BinaryOp>(binary_op));
01619 }
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629 template <typename Sequence1, typename Sequence2, typename T>
01630 decay_t<T> c_inner_product(const Sequence1& factors1, const Sequence2& factors2,
01631 T&& sum) {
01632 return std::inner_product(container_algorithm_internal::c_begin(factors1),
01633 container_algorithm_internal::c_end(factors1),
01634 container_algorithm_internal::c_begin(factors2),
01635 std::forward<T>(sum));
01636 }
01637
01638
01639
01640
01641 template <typename Sequence1, typename Sequence2, typename T,
01642 typename BinaryOp1, typename BinaryOp2>
01643 decay_t<T> c_inner_product(const Sequence1& factors1, const Sequence2& factors2,
01644 T&& sum, BinaryOp1&& op1, BinaryOp2&& op2) {
01645 return std::inner_product(container_algorithm_internal::c_begin(factors1),
01646 container_algorithm_internal::c_end(factors1),
01647 container_algorithm_internal::c_begin(factors2),
01648 std::forward<T>(sum), std::forward<BinaryOp1>(op1),
01649 std::forward<BinaryOp2>(op2));
01650 }
01651
01652
01653
01654
01655
01656
01657 template <typename InputSequence, typename OutputIt>
01658 OutputIt c_adjacent_difference(const InputSequence& input,
01659 OutputIt output_first) {
01660 return std::adjacent_difference(container_algorithm_internal::c_begin(input),
01661 container_algorithm_internal::c_end(input),
01662 output_first);
01663 }
01664
01665
01666
01667 template <typename InputSequence, typename OutputIt, typename BinaryOp>
01668 OutputIt c_adjacent_difference(const InputSequence& input,
01669 OutputIt output_first, BinaryOp&& op) {
01670 return std::adjacent_difference(container_algorithm_internal::c_begin(input),
01671 container_algorithm_internal::c_end(input),
01672 output_first, std::forward<BinaryOp>(op));
01673 }
01674
01675
01676
01677
01678
01679
01680
01681 template <typename InputSequence, typename OutputIt>
01682 OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first) {
01683 return std::partial_sum(container_algorithm_internal::c_begin(input),
01684 container_algorithm_internal::c_end(input),
01685 output_first);
01686 }
01687
01688
01689
01690 template <typename InputSequence, typename OutputIt, typename BinaryOp>
01691 OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first,
01692 BinaryOp&& op) {
01693 return std::partial_sum(container_algorithm_internal::c_begin(input),
01694 container_algorithm_internal::c_end(input),
01695 output_first, std::forward<BinaryOp>(op));
01696 }
01697
01698 }
01699
01700 #endif // ABSL_ALGORITHM_CONTAINER_H_