Created
May 24, 2015 05:10
-
-
Save yllan/ebddec130413946ece77 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| vector<interval_t> pass_lane(vector<interval_t> &gaps, vector<interval_t> &time_intervals) | |
| { | |
| vector<interval_t> result; | |
| // assert: gaps are increasing and non-overlapping. | |
| // assert: time_intervals are increasing and non-overlapping. | |
| int idx = 0; | |
| FOREACH(time_intervals, t) { | |
| while (idx < gaps.size()) { | |
| interval_t g = gaps[idx]; | |
| if (g.first > t->second + time_to_pass_a_lane) break; | |
| interval_t next = intersect(g, make_pair(t->first, t->second + time_to_pass_a_lane)); | |
| next.second -= time_to_pass_a_lane; | |
| if (non_empty(next)) result.push_back(next); | |
| idx++; | |
| } | |
| } | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment