Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion algorithms_task_1/student/include/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@
* @return consecutive range
*/
template<class FI, class Comparator = std::equal_to<typename std::iterator_traits<FI>::value_type>>
std::pair<FI, FI> consecutive_group(FI start, FI end, Comparator comp = {});
std::pair<FI, FI> consecutive_group(FI start, FI end, Comparator comp = {}){
if(start == end) return std::pair<FI, FI> (start, end);

auto first = std::adjacent_find(start, end, comp);
auto endIt = first;
while(endIt != end){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please complete the task with help of algorithms

if(*endIt == *first) endIt++;
else break;
}
return std::pair<FI, FI> (first, endIt );
}