MCPcopy Create free account
hub / github.com/ceph/ceph / span_of

Method span_of

src/include/interval_set.h:913–941  ·  view source on GitHub ↗

* 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] */

Source from the content-addressed store, hash-verified

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

Callers 2

TYPED_TESTFunction · 0.45
build_push_opMethod · 0.45

Calls 4

insertFunction · 0.85
clearFunction · 0.70
find_incMethod · 0.45
endMethod · 0.45

Tested by 1

TYPED_TESTFunction · 0.36