40 #ifndef ABSL_ALGORITHM_CONTAINER_H_ 41 #define ABSL_ALGORITHM_CONTAINER_H_ 47 #include <type_traits> 48 #include <unordered_map> 49 #include <unordered_set> 58 namespace container_algorithm_internal {
74 template <
typename C1,
typename C2>
85 typename std::iterator_traits<ContainerIter<C>>::pointer;
101 template <
typename C>
104 template <
typename T>
107 template <
class Key,
class T,
class Hash,
class KeyEqual,
class Allocator>
109 std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> : std::true_type {};
111 template <
class Key,
class Hash,
class KeyEqual,
class Allocator>
127 template <
typename C,
typename EqualityComparable>
131 std::forward<EqualityComparable>(
value));
142 template <
typename C>
157 template <
typename C,
typename Pred>
161 std::forward<Pred>(pred));
168 template <
typename C,
typename Pred>
172 std::forward<Pred>(pred));
179 template <
typename C,
typename Pred>
183 std::forward<Pred>(pred));
190 template <
typename C,
typename Function>
194 std::forward<Function>(f));
201 template <
typename C,
typename T>
205 std::forward<T>(
value));
212 template <
typename C,
typename Pred>
216 std::forward<Pred>(pred));
223 template <
typename C,
typename Pred>
228 std::forward<Pred>(pred));
235 template <
typename Sequence1,
typename Sequence2>
237 Sequence1& sequence, Sequence2& subsequence) {
246 template <
typename Sequence1,
typename Sequence2,
typename BinaryPredicate>
248 Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
253 std::forward<BinaryPredicate>(pred));
260 template <
typename C1,
typename C2>
271 template <
typename C1,
typename C2,
typename BinaryPredicate>
273 C1& container, C2& options, BinaryPredicate&& pred) {
278 std::forward<BinaryPredicate>(pred));
285 template <
typename Sequence>
287 Sequence& sequence) {
294 template <
typename Sequence,
typename BinaryPredicate>
296 Sequence& sequence, BinaryPredicate&& pred) {
299 std::forward<BinaryPredicate>(pred));
306 template <
typename C,
typename T>
308 const C& c, T&&
value) {
311 std::forward<T>(
value));
318 template <
typename C,
typename Pred>
320 const C& c, Pred&& pred) {
323 std::forward<Pred>(pred));
330 template <
typename C1,
typename C2>
340 template <
typename C1,
typename C2,
typename BinaryPredicate>
346 std::forward<BinaryPredicate>(pred));
366 template <
typename C1,
typename C2>
368 return ((c1.size() == c2.size()) &&
376 template <
typename C1,
typename C2,
typename BinaryPredicate>
377 bool c_equal(
const C1&
c1,
const C2&
c2, BinaryPredicate&& pred) {
378 return ((c1.size() == c2.size()) &&
382 std::forward<BinaryPredicate>(pred)));
389 template <
typename C1,
typename C2>
393 return c1.size() == c2.size() &&
399 template <
typename C1,
typename C2,
typename BinaryPredicate>
403 return c1.size() == c2.size() &&
405 std::forward<BinaryPredicate>(pred));
412 template <
typename Sequence1,
typename Sequence2>
414 Sequence1& sequence, Sequence2& subsequence) {
423 template <
typename Sequence1,
typename Sequence2,
typename BinaryPredicate>
425 Sequence1& sequence, Sequence2& subsequence, BinaryPredicate&& pred) {
430 std::forward<BinaryPredicate>(pred));
437 template <
typename Sequence,
typename Size,
typename T>
439 Sequence& sequence, Size count, T&&
value) {
442 std::forward<T>(
value));
447 template <
typename Sequence,
typename Size,
typename T,
448 typename BinaryPredicate>
450 Sequence& sequence, Size count, T&&
value, BinaryPredicate&& pred) {
453 std::forward<T>(
value),
454 std::forward<BinaryPredicate>(pred));
465 template <
typename InputSequence,
typename OutputIterator>
466 OutputIterator
c_copy(
const InputSequence& input, OutputIterator output) {
475 template <
typename C,
typename Size,
typename OutputIterator>
476 OutputIterator
c_copy_n(
const C& input, Size
n, OutputIterator output) {
484 template <
typename InputSequence,
typename OutputIterator,
typename Pred>
485 OutputIterator
c_copy_if(
const InputSequence& input, OutputIterator output,
489 std::forward<Pred>(pred));
496 template <
typename C,
typename B
idirectionalIterator>
498 BidirectionalIterator dest) {
507 template <
typename C,
typename OutputIterator>
508 OutputIterator
c_move(C&& src, OutputIterator dest) {
517 template <
typename C1,
typename C2>
530 template <
typename InputSequence,
typename OutputIterator,
typename UnaryOp>
531 OutputIterator
c_transform(
const InputSequence& input, OutputIterator output,
532 UnaryOp&& unary_op) {
535 std::forward<UnaryOp>(unary_op));
540 template <
typename InputSequence1,
typename InputSequence2,
541 typename OutputIterator,
typename BinaryOp>
543 const InputSequence2& input2, OutputIterator output,
544 BinaryOp&& binary_op) {
548 std::forward<BinaryOp>(binary_op));
556 template <
typename Sequence,
typename T>
568 template <
typename C,
typename Pred,
typename T>
572 std::forward<Pred>(pred), std::forward<T>(new_value));
580 template <
typename C,
typename OutputIterator,
typename T>
586 std::forward<T>(new_value));
594 template <
typename C,
typename OutputIterator,
typename Pred,
typename T>
599 std::forward<Pred>(pred),
600 std::forward<T>(new_value));
607 template <
typename C,
typename T>
617 template <
typename C,
typename Size,
typename T>
620 std::forward<T>(
value));
627 template <
typename C,
typename Generator>
631 std::forward<Generator>(gen));
639 template <
typename C,
typename Size,
typename Generator>
643 std::forward<Generator>(gen));
656 template <
typename C,
typename OutputIterator,
typename T>
660 std::forward<T>(
value));
668 template <
typename C,
typename OutputIterator,
typename Pred>
673 std::forward<Pred>(pred));
681 template <
typename C,
typename OutputIterator>
689 template <
typename C,
typename OutputIterator,
typename BinaryPredicate>
691 BinaryPredicate&& pred) {
694 std::forward<BinaryPredicate>(pred));
701 template <
typename Sequence>
711 template <
typename C,
typename OutputIterator>
723 template <
typename C,
735 template <
typename C,
typename OutputIterator>
739 OutputIterator result) {
750 template <
typename RandomAccessContainer,
typename UniformRandomBitGenerator>
751 void c_shuffle(RandomAccessContainer& c, UniformRandomBitGenerator&& gen) {
754 std::forward<UniformRandomBitGenerator>(gen));
766 template <
typename C,
typename Pred>
770 std::forward<Pred>(pred));
779 template <
typename C,
typename Pred>
783 std::forward<Pred>(pred));
793 template <
typename C,
typename Pred>
798 std::forward<Pred>(pred));
807 template <
typename C,
typename OutputIterator1,
typename OutputIterator2,
810 const C& c, OutputIterator1 out_true, OutputIterator2 out_false,
814 out_false, std::forward<Pred>(pred));
822 template <
typename C,
typename Pred>
827 std::forward<Pred>(pred));
838 template <
typename C>
846 template <
typename C,
typename Compare>
850 std::forward<Compare>(comp));
858 template <
typename C>
866 template <
typename C,
typename Compare>
870 std::forward<Compare>(comp));
877 template <
typename C>
885 template <
typename C,
typename Compare>
889 std::forward<Compare>(comp));
897 template <
typename RandomAccessContainer>
899 RandomAccessContainer& sequence,
907 template <
typename RandomAccessContainer,
typename Compare>
909 RandomAccessContainer& sequence,
914 std::forward<Compare>(comp));
923 template <
typename C,
typename RandomAccessContainer>
934 template <
typename C,
typename RandomAccessContainer,
typename Compare>
942 std::forward<Compare>(comp));
950 template <
typename C>
958 template <
typename C,
typename Compare>
963 std::forward<Compare>(comp));
973 template <
typename RandomAccessContainer>
975 RandomAccessContainer& sequence,
983 template <
typename RandomAccessContainer,
typename Compare>
985 RandomAccessContainer& sequence,
990 std::forward<Compare>(comp));
1002 template <
typename Sequence,
typename T>
1004 Sequence& sequence, T&&
value) {
1007 std::forward<T>(
value));
1012 template <
typename Sequence,
typename T,
typename Compare>
1017 std::forward<T>(
value), std::forward<Compare>(comp));
1025 template <
typename Sequence,
typename T>
1027 Sequence& sequence, T&&
value) {
1030 std::forward<T>(
value));
1035 template <
typename Sequence,
typename T,
typename Compare>
1040 std::forward<T>(
value), std::forward<Compare>(comp));
1048 template <
typename Sequence,
typename T>
1053 std::forward<T>(
value));
1058 template <
typename Sequence,
typename T,
typename Compare>
1063 std::forward<T>(
value), std::forward<Compare>(comp));
1071 template <
typename Sequence,
typename T>
1075 std::forward<T>(
value));
1080 template <
typename Sequence,
typename T,
typename Compare>
1084 std::forward<T>(
value),
1085 std::forward<Compare>(comp));
1096 template <
typename C1,
typename C2,
typename OutputIterator>
1097 OutputIterator
c_merge(
const C1&
c1,
const C2&
c2, OutputIterator result) {
1106 template <
typename C1,
typename C2,
typename OutputIterator,
typename Compare>
1107 OutputIterator
c_merge(
const C1&
c1,
const C2&
c2, OutputIterator result,
1113 std::forward<Compare>(comp));
1120 template <
typename C>
1129 template <
typename C,
typename Compare>
1135 std::forward<Compare>(comp));
1143 template <
typename C1,
typename C2>
1153 template <
typename C1,
typename C2,
typename Compare>
1159 std::forward<Compare>(comp));
1167 template <
typename C1,
typename C2,
typename OutputIterator,
1168 typename =
typename std::enable_if<
1171 typename =
typename std::enable_if<
1183 template <
typename C1,
typename C2,
typename OutputIterator,
typename Compare,
1184 typename =
typename std::enable_if<
1187 typename =
typename std::enable_if<
1196 std::forward<Compare>(comp));
1203 template <
typename C1,
typename C2,
typename OutputIterator,
1204 typename =
typename std::enable_if<
1207 typename =
typename std::enable_if<
1211 OutputIterator output) {
1220 template <
typename C1,
typename C2,
typename OutputIterator,
typename Compare,
1221 typename =
typename std::enable_if<
1224 typename =
typename std::enable_if<
1228 OutputIterator output, Compare&& comp) {
1233 std::forward<Compare>(comp));
1241 template <
typename C1,
typename C2,
typename OutputIterator,
1242 typename =
typename std::enable_if<
1245 typename =
typename std::enable_if<
1249 OutputIterator output) {
1258 template <
typename C1,
typename C2,
typename OutputIterator,
typename Compare,
1259 typename =
typename std::enable_if<
1262 typename =
typename std::enable_if<
1266 OutputIterator output, Compare&& comp) {
1271 std::forward<Compare>(comp));
1279 template <
typename C1,
typename C2,
typename OutputIterator,
1280 typename =
typename std::enable_if<
1283 typename =
typename std::enable_if<
1287 OutputIterator output) {
1288 return std::set_symmetric_difference(
1297 template <
typename C1,
typename C2,
typename OutputIterator,
typename Compare,
1298 typename =
typename std::enable_if<
1301 typename =
typename std::enable_if<
1305 OutputIterator output,
1307 return std::set_symmetric_difference(
1312 std::forward<Compare>(comp));
1323 template <
typename RandomAccessContainer>
1331 template <
typename RandomAccessContainer,
typename Compare>
1335 std::forward<Compare>(comp));
1342 template <
typename RandomAccessContainer>
1350 template <
typename RandomAccessContainer,
typename Compare>
1351 void c_pop_heap(RandomAccessContainer& sequence, Compare&& comp) {
1354 std::forward<Compare>(comp));
1361 template <
typename RandomAccessContainer>
1369 template <
typename RandomAccessContainer,
typename Compare>
1373 std::forward<Compare>(comp));
1380 template <
typename RandomAccessContainer>
1388 template <
typename RandomAccessContainer,
typename Compare>
1392 std::forward<Compare>(comp));
1399 template <
typename RandomAccessContainer>
1407 template <
typename RandomAccessContainer,
typename Compare>
1408 bool c_is_heap(
const RandomAccessContainer& sequence, Compare&& comp) {
1411 std::forward<Compare>(comp));
1418 template <
typename RandomAccessContainer>
1427 template <
typename RandomAccessContainer,
typename Compare>
1432 std::forward<Compare>(comp));
1444 template <
typename Sequence>
1446 Sequence& sequence) {
1453 template <
typename Sequence,
typename Compare>
1455 Sequence& sequence, Compare&& comp) {
1458 std::forward<Compare>(comp));
1466 template <
typename Sequence>
1468 Sequence& sequence) {
1475 template <
typename Sequence,
typename Compare>
1477 Sequence& sequence, Compare&& comp) {
1480 std::forward<Compare>(comp));
1489 template <
typename C>
1498 template <
typename C,
typename Compare>
1503 std::forward<Compare>(comp));
1517 template <
typename Sequence1,
typename Sequence2>
1519 return std::lexicographical_compare(
1528 template <
typename Sequence1,
typename Sequence2,
typename Compare>
1531 return std::lexicographical_compare(
1536 std::forward<Compare>(comp));
1544 template <
typename C>
1552 template <
typename C,
typename Compare>
1556 std::forward<Compare>(comp));
1564 template <
typename C>
1572 template <
typename C,
typename Compare>
1576 std::forward<Compare>(comp));
1588 template <
typename Sequence,
typename T>
1592 std::forward<T>(
value));
1603 template <
typename Sequence,
typename T>
1607 std::forward<T>(init));
1612 template <
typename Sequence,
typename T,
typename BinaryOp>
1614 BinaryOp&& binary_op) {
1617 std::forward<T>(init),
1618 std::forward<BinaryOp>(binary_op));
1629 template <
typename Sequence1,
typename Sequence2,
typename T>
1635 std::forward<T>(sum));
1641 template <
typename Sequence1,
typename Sequence2,
typename T,
1642 typename BinaryOp1,
typename BinaryOp2>
1644 T&& sum, BinaryOp1&& op1, BinaryOp2&& op2) {
1648 std::forward<T>(sum), std::forward<BinaryOp1>(op1),
1649 std::forward<BinaryOp2>(op2));
1657 template <
typename InputSequence,
typename OutputIt>
1659 OutputIt output_first) {
1667 template <
typename InputSequence,
typename OutputIt,
typename BinaryOp>
1669 OutputIt output_first, BinaryOp&& op) {
1672 output_first, std::forward<BinaryOp>(op));
1681 template <
typename InputSequence,
typename OutputIt>
1690 template <
typename InputSequence,
typename OutputIt,
typename BinaryOp>
1695 output_first, std::forward<BinaryOp>(op));
1700 #endif // ABSL_ALGORITHM_CONTAINER_H_ void c_iota(Sequence &sequence, T &&value)
BidirectionalIterator c_copy_backward(const C &src, BidirectionalIterator dest)
bool c_is_partitioned(const C &c, Pred &&pred)
container_algorithm_internal::ContainerIter< C1 > c_find_first_of(C1 &container, C2 &options)
void c_replace(Sequence &sequence, const T &old_value, const T &new_value)
OutputIterator c_replace_copy_if(const C &c, OutputIterator result, Pred &&pred, T &&new_value)
decltype(std::distance(std::declval< ContainerIter< C >>(), std::declval< ContainerIter< C >>())) ContainerDifferenceType
void c_pop_heap(RandomAccessContainer &sequence)
void c_shuffle(RandomAccessContainer &c, UniformRandomBitGenerator &&gen)
OutputIterator c_merge(const C1 &c1, const C2 &c2, OutputIterator result)
container_algorithm_internal::ContainerDifferenceType< const C > c_count(const C &c, T &&value)
container_algorithm_internal::ContainerIter< RandomAccessContainer > c_partial_sort_copy(const C &sequence, RandomAccessContainer &result)
container_algorithm_internal::ContainerIter< Sequence > c_max_element(Sequence &sequence)
OutputIterator c_copy_n(const C &input, Size n, OutputIterator output)
container_algorithm_internal::ContainerIterPairType< C, C > c_minmax_element(C &c)
bool c_any_of(const C &c, Pred &&pred)
typename std::decay< T >::type decay_t
typename std::iterator_traits< ContainerIter< C >>::pointer ContainerPointerType
void c_reverse(Sequence &sequence)
bool c_is_permutation(const C1 &c1, const C2 &c2)
container_algorithm_internal::ContainerIter< C2 > c_swap_ranges(C1 &c1, C2 &c2)
Iterator c_rotate(C &sequence, Iterator middle)
void c_nth_element(RandomAccessContainer &sequence, container_algorithm_internal::ContainerIter< RandomAccessContainer > nth)
bool c_lexicographical_compare(Sequence1 &&sequence1, Sequence2 &&sequence2)
container_algorithm_internal::ContainerIter< C > c_partition_point(C &c, Pred &&pred)
container_algorithm_internal::ContainerIter< Sequence1 > c_search(Sequence1 &sequence, Sequence2 &subsequence)
container_algorithm_internal::ContainerIter< C > c_find(C &c, T &&value)
container_algorithm_internal::ContainerIter< C > c_stable_partition(C &c, Pred &&pred)
container_algorithm_internal::ContainerDifferenceType< const C > c_count_if(const C &c, Pred &&pred)
void c_fill_n(C &c, Size n, T &&value)
container_algorithm_internal::ContainerIter< RandomAccessContainer > c_is_heap_until(RandomAccessContainer &sequence)
void c_sort_heap(RandomAccessContainer &sequence)
decay_t< Function > c_for_each(C &&c, Function &&f)
OutputIterator c_remove_copy_if(const C &c, OutputIterator result, Pred &&pred)
container_algorithm_internal::ContainerIter< C > c_generate_n(C &c, Size n, Generator &&gen)
container_algorithm_internal::ContainerDifferenceType< const C > c_distance(const C &c)
OutputIterator c_remove_copy(const C &c, OutputIterator result, T &&value)
decay_t< T > c_inner_product(const Sequence1 &factors1, const Sequence2 &factors2, T &&sum)
bool c_equal(const C1 &c1, const C2 &c2)
container_algorithm_internal::ContainerIter< Sequence > c_adjacent_find(Sequence &sequence)
void c_make_heap(RandomAccessContainer &sequence)
bool c_prev_permutation(C &c)
OutputIterator c_rotate_copy(const C &sequence, container_algorithm_internal::ContainerIter< const C > middle, OutputIterator result)
decltype(std::make_pair(ContainerIter< C1 >(), ContainerIter< C2 >())) ContainerIterPairType
OutputIterator c_reverse_copy(const C &sequence, OutputIterator result)
std::pair< OutputIterator1, OutputIterator2 > c_partition_copy(const C &c, OutputIterator1 out_true, OutputIterator2 out_false, Pred &&pred)
container_algorithm_internal::ContainerIterPairType< C1, C2 > c_mismatch(C1 &c1, C2 &c2)
OutputIterator c_copy(const InputSequence &input, OutputIterator output)
OutputIterator c_set_symmetric_difference(const C1 &c1, const C2 &c2, OutputIterator output)
OutputIterator c_copy_if(const InputSequence &input, OutputIterator output, Pred &&pred)
OutputIterator c_unique_copy(const C &c, OutputIterator result)
bool linear_search(InputIterator first, InputIterator last, const EqualityComparable &value)
bool c_includes(const C1 &c1, const C2 &c2)
bool c_binary_search(Sequence &&sequence, T &&value)
void c_inplace_merge(C &c, container_algorithm_internal::ContainerIter< C > middle)
void c_fill(C &c, T &&value)
container_algorithm_internal::ContainerIterPairType< Sequence, Sequence > c_equal_range(Sequence &sequence, T &&value)
OutputIterator c_move(C &&src, OutputIterator dest)
bool c_linear_search(const C &c, EqualityComparable &&value)
bool c_all_of(const C &c, Pred &&pred)
container_algorithm_internal::ContainerIter< C > c_find_if(C &c, Pred &&pred)
OutputIt c_adjacent_difference(const InputSequence &input, OutputIt output_first)
container_algorithm_internal::ContainerIter< Sequence > c_search_n(Sequence &sequence, Size count, T &&value)
bool c_next_permutation(C &c)
container_algorithm_internal::ContainerIter< Sequence > c_min_element(Sequence &sequence)
ContainerIter< C > c_begin(C &c)
OutputIterator c_replace_copy(const C &c, OutputIterator result, T &&old_value, T &&new_value)
bool c_is_heap(const RandomAccessContainer &sequence)
ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last)
void c_push_heap(RandomAccessContainer &sequence)
void c_generate(C &c, Generator &&gen)
container_algorithm_internal::ContainerIter< Sequence > c_upper_bound(Sequence &sequence, T &&value)
OutputIterator c_set_intersection(const C1 &c1, const C2 &c2, OutputIterator output)
OutputIt c_partial_sum(const InputSequence &input, OutputIt output_first)
OutputIterator c_transform(const InputSequence &input, OutputIterator output, UnaryOp &&unary_op)
container_algorithm_internal::ContainerIter< Sequence1 > c_find_end(Sequence1 &sequence, Sequence2 &subsequence)
decay_t< T > c_accumulate(const Sequence &sequence, T &&init)
void c_partial_sort(RandomAccessContainer &sequence, container_algorithm_internal::ContainerIter< RandomAccessContainer > middle)
OutputIterator c_set_union(const C1 &c1, const C2 &c2, OutputIterator output)
bool c_is_sorted(const C &c)
void c_replace_if(C &c, Pred &&pred, T &&new_value)
decltype(begin(std::declval< C & >())) ContainerIter
container_algorithm_internal::ContainerIter< C > c_partition(C &c, Pred &&pred)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
int Compare(const BigUnsigned< N > &lhs, const BigUnsigned< M > &rhs)
container_algorithm_internal::ContainerIter< C > c_find_if_not(C &c, Pred &&pred)
container_algorithm_internal::ContainerIter< Sequence > c_lower_bound(Sequence &sequence, T &&value)
ContainerIter< C > c_end(C &c)
OutputIterator c_set_difference(const C1 &c1, const C2 &c2, OutputIterator output)
bool c_none_of(const C &c, Pred &&pred)
container_algorithm_internal::ContainerIter< C > c_is_sorted_until(C &c)