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

Class iterator

src/common/interval_map.h:282–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280 }
281
282 class iterator {
283 Mapiter it;
284 bool end;
285 iterator(Mapiter &&it, bool end) : it(std::move(it)), end(end) {}
286
287 friend class interval_map;
288 public:
289 iterator(const iterator &) = default;
290 iterator &operator=(const iterator &) = default;
291
292 iterator &operator++() {
293 /* While the buffer can be modified with a non-const iterator, it
294 * not change size. Allow changes in size would allow for the interval
295 * to be merged into the next one, which would allow for unexpected
296 * behaviour.
297 */
298 if (!end && get_val().length() != get_len()) {
299 throw std::out_of_range("buffer length has changed");
300 }
301 ++it;
302 return *this;
303 }
304 iterator operator++(int) {
305 return const_iterator(it++);
306 }
307 iterator &operator--() {
308 --it;
309 return *this;
310 }
311 iterator operator--(int) {
312 return const_iterator(it--);
313 }
314 bool operator==(const iterator &rhs) const {
315 return it == rhs.it;
316 }
317 bool operator!=(const iterator &rhs) const {
318 return it != rhs.it;
319 }
320 K get_off() const {
321 return it->first;
322 }
323 K get_len() const {
324 return it->second.first;
325 }
326 V &get_val() {
327 return it->second.second;
328 }
329 iterator &operator*() {
330 return *this;
331 }
332 constexpr bool contains(K _off, K _len) const {
333 K off = get_off();
334 K len = get_len();
335 return off <= _off && _off + _len <= off + len;
336 }
337 };
338 static constexpr bool nonconst_iterator_cond() { return nonconst_iterator; }
339 iterator begin() requires (nonconst_iterator) {

Callers 5

eraseMethod · 0.70
beginMethod · 0.70
findMethod · 0.70
beginMethod · 0.70
endMethod · 0.70

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected