MCPcopy Create free account
hub / github.com/DFHack/dfhack / iterator

Class iterator

library/include/BitArray.h:288–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286 class const_iterator;
287
288 class iterator
289 {
290 L *root;
291 L *cur;
292 friend struct DfLinkedList<L, I>;
293 friend class const_iterator;
294 iterator(L *root, L *cur) : root(root), cur(cur) {}
295 public:
296 using difference_type = std::ptrdiff_t;
297 using value_type = I *;
298 using pointer = I **;
299 using reference = I *&;
300 using iterator_category = std::bidirectional_iterator_tag;
301
302 iterator() : root(nullptr), cur(nullptr) {}
303 iterator(const iterator & other) : root(other.root), cur(other.cur) {}
304
305 iterator & operator++()
306 {
307 CHECK_NULL_POINTER(root);
308 CHECK_NULL_POINTER(cur);
309
310 cur = cur->next;
311 return *this;
312 }
313 iterator & operator--()
314 {
315 CHECK_NULL_POINTER(root);
316
317 if (!cur)
318 {
319 // find end() - 1
320 for (cur = root->next; cur && cur->next; cur = cur->next)
321 {
322 }
323 return *this;
324 }
325
326 CHECK_NULL_POINTER(cur);
327 CHECK_NULL_POINTER(cur->prev);
328
329 cur = cur->prev;
330 return *this;
331 }
332 iterator operator++(int)
333 {
334 iterator copy(*this);
335 ++*this;
336 return copy;
337 }
338 iterator operator--(int)
339 {
340 iterator copy(*this);
341 --*this;
342 return copy;
343 }
344 iterator & operator=(const iterator & other)
345 {

Callers 11

beginMethod · 0.85
endMethod · 0.85
eraseMethod · 0.85
insertMethod · 0.85
insert_afterMethod · 0.85
operator++Method · 0.85
operator--Method · 0.85
operator++Method · 0.85
operator--Method · 0.85
beginMethod · 0.85
endMethod · 0.85

Calls 1

const_iteratorClass · 0.85

Tested by

no test coverage detected