diff options
Diffstat (limited to 'absl/algorithm/algorithm.h')
-rw-r--r-- | absl/algorithm/algorithm.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/absl/algorithm/algorithm.h b/absl/algorithm/algorithm.h index bb90215d..771228a0 100644 --- a/absl/algorithm/algorithm.h +++ b/absl/algorithm/algorithm.h @@ -84,6 +84,8 @@ It RotateImpl(It first, It middle, It last, std::false_type) { } // namespace algorithm_internal +// equal() +// // Compares the equality of two ranges specified by pairs of iterators, using // the given predicate, returning true iff for each corresponding iterator i1 // and i2 in the first and second range respectively, pred(*i1, *i2) == true @@ -104,8 +106,8 @@ bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2, typename std::iterator_traits<InputIter2>::iterator_category{}); } -// Performs comparison of two ranges specified by pairs of iterators using -// operator==. +// Overload of equal() that performs comparison of two ranges specified by pairs +// of iterators using operator==. template <typename InputIter1, typename InputIter2> bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2, InputIter2 last2) { @@ -113,6 +115,8 @@ bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2, algorithm_internal::EqualTo{}); } +// linear_search() +// // Performs a linear search for `value` using the iterator `first` up to // but not including `last`, returning true if [`first`, `last`) contains an // element equal to `value`. @@ -126,6 +130,8 @@ bool linear_search(InputIterator first, InputIterator last, return std::find(first, last, value) != last; } +// rotate() +// // Performs a left rotation on a range of elements (`first`, `last`) such that // `middle` is now the first element. `rotate()` returns an iterator pointing to // the first element before rotation. This function is exactly the same as @@ -135,7 +141,6 @@ bool linear_search(InputIterator first, InputIterator last, // The complexity of this algorithm is the same as that of `std::rotate`, but if // `ForwardIterator` is not a random-access iterator, then `absl::rotate` // performs an additional pass over the range to construct the return value. - template <typename ForwardIterator> ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) { |