- Fix typo in util function name for_each_indexed. - Use the overloaded functions for_each_indexed and for_each_pair with a container argument where possible to improve readability.
		
			
				
	
	
		
			32 lines
		
	
	
		
			659 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			659 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #ifndef FOR_EACH_INDEXED_HPP
 | |
| #define FOR_EACH_INDEXED_HPP
 | |
| 
 | |
| #include <iterator>
 | |
| #include <numeric>
 | |
| #include <utility>
 | |
| 
 | |
| namespace osrm
 | |
| {
 | |
| namespace util
 | |
| {
 | |
| 
 | |
| template <typename ForwardIterator, typename Function>
 | |
| void for_each_indexed(ForwardIterator first, ForwardIterator last, Function function)
 | |
| {
 | |
|     for (size_t i = 0; first != last; ++first, ++i)
 | |
|     {
 | |
|         function(i, *first);
 | |
|     }
 | |
| }
 | |
| 
 | |
| template <class ContainerT, typename Function>
 | |
| void for_each_indexed(ContainerT &container, Function function)
 | |
| {
 | |
|     for_each_indexed(std::begin(container), std::end(container), function);
 | |
| }
 | |
| 
 | |
| } // namespace util
 | |
| } // namespace osrm
 | |
| 
 | |
| #endif /* FOR_EACH_INDEXED_HPP */
 |