! * Improved efficiency by storing direct access to data layers. */
| 32 | * Improved efficiency by storing direct access to data layers. |
| 33 | */ |
| 34 | void runGridMapIteratorVersion2(GridMap& map, const string& layer_from, const string& layer_to) |
| 35 | { |
| 36 | const auto& data_from = map[layer_from]; |
| 37 | auto& data_to = map[layer_to]; |
| 38 | for (GridMapIterator iterator(map); !iterator.isPastEnd(); ++iterator) { |
| 39 | const Index index(*iterator); |
| 40 | const float value_from = data_from(index(0), index(1)); |
| 41 | float& value_to = data_to(index(0), index(1)); |
| 42 | value_to = value_to > value_from ? value_to : value_from; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /*! |
| 47 | * Improved efficiency by using linear index. |