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

Function linked_list_remove

library/include/MiscUtils.h:326–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324 */
325template <typename L, typename V = L::iterator::value_type, std::invocable<V> F>
326bool linked_list_remove(L *list, F matches) {
327 auto matches_wrapper = [&](L::iterator::value_type item) {
328 return item && matches(item);
329 };
330 typename L::const_iterator it = std::find_if(list->cbegin(), list->cend(), matches_wrapper);
331 if (it == list->cend())
332 return false;
333 auto item = *it;
334 list->erase(it);
335 delete item;
336 return true;
337}
338
339/**
340 * Returns true if the item with id idToRemove was found, deleted, and

Callers 2

detachItemFunction · 0.85
teleportMethod · 0.85

Calls 4

cbeginMethod · 0.80
cendMethod · 0.80
matchesFunction · 0.50
eraseMethod · 0.45

Tested by

no test coverage detected