-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rips out dead code from the container.hpp and creates for_each_pai.hpp
I added two TODOs that I would like to address in the future.
- Loading branch information
1 parent
f682476
commit b8e586b
Showing
9 changed files
with
63 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef FOR_EACH_PAIR_HPP | ||
#define FOR_EACH_PAIR_HPP | ||
|
||
#include <numeric> | ||
#include <iterator> | ||
|
||
namespace osrm | ||
{ | ||
namespace util | ||
{ | ||
|
||
// TODO: check why this is not an option here: | ||
// std::adjacent_find(begin, end, [=](const auto& l, const auto& r){ return function(), false; }); | ||
template <typename ForwardIterator, typename Function> | ||
Function for_each_pair(ForwardIterator begin, ForwardIterator end, Function function) | ||
{ | ||
if (begin == end) | ||
{ | ||
return function; | ||
} | ||
|
||
auto next = begin; | ||
next = std::next(next); | ||
|
||
while (next != end) | ||
{ | ||
function(*begin, *next); | ||
begin = std::next(begin); | ||
next = std::next(next); | ||
} | ||
return function; | ||
} | ||
|
||
template <class ContainerT, typename Function> | ||
Function for_each_pair(ContainerT &container, Function function) | ||
{ | ||
using std::begin; | ||
using std::end; | ||
return for_each_pair(begin(container), end(container), function); | ||
} | ||
|
||
} // namespace util | ||
} // namespace osrm | ||
|
||
#endif /* FOR_EACH_PAIR_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters