/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* lexicographical_compare.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/11/28 14:58:42 by apommier #+# #+# */ /* Updated: 2022/11/29 17:28:55 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once namespace ft { template bool lexicographical_compare (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2) { while (first1!=last1) { if (first2 == last2 || *first2 < *first1) return false; else if (*first1 < *first2) return true; ++first1; ++first2; } return (first2 != last2); } template bool lexicographical_compare (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp) { while (first1 != last1) { if (comp(*first1, *first2)) return true; if (comp(*first2, *first1)) return false; ++first1; ++first2; } return (first2 != last2); } }