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

Method erase

library/include/BitArray.h:501–530  ·  view source on GitHub ↗

* This erases the cell at the location of the iterator, but not the item pointed to by that cell. * When using this with lists that own the items being pointed to (e.g. world->jobs.list), it is the * responsibility of the caller to avoid memory leaks. */

Source from the content-addressed store, hash-verified

499 * responsibility of the caller to avoid memory leaks.
500 */
501 iterator erase(const_iterator pos)
502 {
503 auto root = static_cast<L *>(this);
504 CHECK_INVALID_ARGUMENT(pos.iter.root == root);
505 CHECK_NULL_POINTER(pos.iter.cur);
506
507 auto link = pos.iter.cur;
508 auto next = link->next;
509
510 if (link->prev)
511 {
512 link->prev->next = link->next;
513 }
514 else
515 {
516 root->next = link->next;
517 }
518
519 if (link->next)
520 {
521 link->next->prev = link->prev;
522 }
523
524 if (link->item)
525 link->item->dfhack_set_list_link(nullptr);
526
527 delete link;
528
529 return iterator(root, next);
530 }
531
532 iterator insert(const_iterator pos, I *const & item)
533 {

Callers

nothing calls this directly

Calls 1

iteratorClass · 0.85

Tested by

no test coverage detected