auto lst = m.lower_bound(off + len);
return std::make_pair(fst, lst);
}
+ cmapiter get_range_fst(K off) const {
+ // fst is first iterator with end after off (may be end)
+ auto fst = m.upper_bound(off);
+ if (fst != m.begin())
+ --fst;
+ if (fst != m.end() && off >= (fst->first + fst->second.first))
+ ++fst;
+
+ return fst;
+ }
void try_merge(mapiter niter) {
if (niter != m.begin()) {
auto prev = niter;
auto rng = get_range(off, len);
return std::make_pair(const_iterator(rng.first), const_iterator(rng.second));
}
+
+ const_iterator get_lower_range(
+ K off,
+ K len) const {
+ return const_iterator(get_range_fst(off, len));
+ }
+ K get_start_off() const
+ {
+ auto i = m.begin();
+ ceph_assert(i != m.end());
+ return i->first;
+ }
+ K get_end_off() const
+ {
+ auto i = m.rbegin();
+ ceph_assert(i != m.rend());
+ return i->first + i->second.first;
+ }
+ bool contains(K off, K len) const {
+ auto it = get_range_fst(off, len);
+ if (it == m.end()) return false;
+
+ K _off = it->first;
+ K _len = it->second.first;
+ return _off <= off && _off + _len >= off + len;
+ }
unsigned ext_count() const {
return m.size();
}