diff --git a/pc_container.hh b/pc_container.hh index 3ba7cb4..115c4a5 100644 --- a/pc_container.hh +++ b/pc_container.hh @@ -58,6 +58,12 @@ public: c.erase(pos); } + // removes all elements with pdata==null && cdata==null + void compact() + { + c.remove_if( [](const PC& elem) { return elem.pdata==nullptr && elem.cdata==nullptr; } ); + } + // clear the container. Delete all *pdata via custom deleter functor. void clear(std::function deleter = [](Pdata *e) { delete e; }) {