From c652ca1d7c154a983faba5f6900df394df39c1ba Mon Sep 17 00:00:00 2001 From: Roker Date: Mon, 22 Oct 2018 23:03:39 +0200 Subject: [PATCH] add compact() --- pc_container.hh | 6 ++++++ 1 file changed, 6 insertions(+) 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; }) {