* build a subset of @other, starting at or after @start, and including * @len worth of values, skipping holes. e.g., * span_of([5~10,20~5], 8, 5) -> [8~2,20~3] */
| 911 | * span_of([5~10,20~5], 8, 5) -> [8~2,20~3] |
| 912 | */ |
| 913 | void span_of(const interval_set &other, T start, T len) { |
| 914 | clear(); |
| 915 | auto p = other.find_inc(start); |
| 916 | if (p == other.m.end()) |
| 917 | return; |
| 918 | if (p->first < start) { |
| 919 | if (p->first + p->second < start) |
| 920 | return; |
| 921 | if (p->first + p->second < start + len) { |
| 922 | T howmuch = p->second - (start - p->first); |
| 923 | insert(start, howmuch); |
| 924 | len -= howmuch; |
| 925 | p++; |
| 926 | } else { |
| 927 | insert(start, len); |
| 928 | return; |
| 929 | } |
| 930 | } |
| 931 | while (p != other.m.end() && len > 0) { |
| 932 | if (p->second < len) { |
| 933 | insert(p->first, p->second); |
| 934 | len -= p->second; |
| 935 | p++; |
| 936 | } else { |
| 937 | insert(p->first, len); |
| 938 | return; |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | /* |
| 944 | * Move contents of m into another Map. Use that instead of |