vector finish

This commit is contained in:
hugogogo
2022-06-14 21:25:16 +02:00
parent 988d67e908
commit 005382a3ac
11 changed files with 584 additions and 71 deletions

View File

@@ -0,0 +1,42 @@
#ifndef LEXICOGRAPHICAL_COMPARE_HPP
# define LEXICOGRAPHICAL_COMPARE_HPP
namespace ft {
template <class InputIt1, class InputIt2>
bool lexicographical_compare
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) {
while (first1 != last1)
{
if (first2 == last2 || *first2 < *first1)
return false;
else if (*first1 < *first2)
return true;
++first1;
++first2;
}
return (first2 != last2);
}
template <class InputIt1, class InputIt2, class Compare>
bool lexicographical_compare
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) {
while (first1 != last1)
{
if (first2 == last2 || comp(*first2, *first1))
return false;
else if (comp(*first1, *first2))
return true;
++first1;
++first2;
}
return (first2 != last2);
}
} // namespace ft
#endif