From 0c54127815c547748978c6c1960db5c9e7966cb0 Mon Sep 17 00:00:00 2001 From: Claros Alexis Date: Mon, 20 Feb 2023 18:28:30 +0100 Subject: [PATCH] task completed --- algorithms_task_1/student/include/impl.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/algorithms_task_1/student/include/impl.h b/algorithms_task_1/student/include/impl.h index 350adfaf..2bd70ce2 100644 --- a/algorithms_task_1/student/include/impl.h +++ b/algorithms_task_1/student/include/impl.h @@ -11,4 +11,14 @@ * @return consecutive range */ template::value_type>> -std::pair consecutive_group(FI start, FI end, Comparator comp = {}); +std::pair consecutive_group(FI start, FI end, Comparator comp = {}){ + if(start == end) return std::pair (start, end); + + auto first = std::adjacent_find(start, end, comp); + auto endIt = first; + while(endIt != end){ + if(*endIt == *first) endIt++; + else break; + } + return std::pair (first, endIt ); +}