From eba0d786173f19e9aebfdaaa1a07253f15a47818 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 24 Jul 2020 20:24:10 +0800 Subject: [PATCH] add ClearActive() in Pool template. --- inc/hgl/type/Pool.cpp | 11 +++++++++++ inc/hgl/type/Pool.h | 1 + 2 files changed, 12 insertions(+) diff --git a/inc/hgl/type/Pool.cpp b/inc/hgl/type/Pool.cpp index d29c90d..4f37530 100644 --- a/inc/hgl/type/Pool.cpp +++ b/inc/hgl/type/Pool.cpp @@ -139,6 +139,17 @@ namespace hgl } } + template + void Pool::ClearActive() + { + T *p=Active.GetData(); + int ac=Active.GetCount(); + + Inactive.Push(p,ac); + + Active.ClearData(); + } + template void Pool::ClearInactive() { diff --git a/inc/hgl/type/Pool.h b/inc/hgl/type/Pool.h index 0bd7c08..594d8f9 100644 --- a/inc/hgl/type/Pool.h +++ b/inc/hgl/type/Pool.h @@ -58,6 +58,7 @@ namespace hgl bool IsActive(const T &data)const{return Active.IsExist(data);} bool IsInactive(const T &data)const{return Inactive.IsExist(data);} + virtual void ClearActive(); ///<清除所有活跃的 virtual void ClearInactive(); ///<清除所有空闲的 virtual void ClearAll(); ///<清除所有的 };//template class Pool