From 974d05002540d834fc923ff54417fd790ab8e678 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 12 Dec 2018 07:31:51 +0000 Subject: [PATCH] =?UTF-8?q?EgtGeomKernel=20:=20-=20migliorie=20a=20IdManag?= =?UTF-8?q?er=20per=20aggiornamento=20dopo=20cancellazione=20entit=C3=A0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IdManager.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/IdManager.h b/IdManager.h index 8921530..744e3eb 100644 --- a/IdManager.h +++ b/IdManager.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2013-2013 +// EgalTech 2013-2018 //---------------------------------------------------------------------------- -// File : IdManager.h Data : 02.12.13 Versione : 1.4a3 +// File : IdManager.h Data : 11.12.18 Versione : 1.9l2 // Contenuto : Dichiarazione e implementazione della classe IdManager. // // @@ -14,8 +14,6 @@ #pragma once #include -#include - //---------------------------------------------------------------------------- class IdManager @@ -45,8 +43,7 @@ class IdManager return m_GdbIdMap.emplace( nId, pGObj).second ; } bool RemoveObj( int nId) { m_GdbIdMap.erase( nId) ; - if ( nId == m_nMaxId && m_nMaxId > 0) - UpdateMaxId() ; + UpdateMaxId() ; return true ; } int GetNewId( void) const { return ( m_nMaxId + 1) ; } @@ -56,14 +53,12 @@ class IdManager { if ( nId > m_nMaxId) m_nMaxId = nId ; } void UpdateMaxId( void) - { int nMaxId = 0 ; - if ( m_GdbIdMap.find( m_nMaxId - 1) != m_GdbIdMap.end()) { - -- m_nMaxId ; - return ; - } - for (const auto& Igdbo : m_GdbIdMap) - nMaxId = std::max( nMaxId, Igdbo.first) ; - m_nMaxId = nMaxId ; } + { while ( m_nMaxId > 0) { + if ( m_GdbIdMap.find( m_nMaxId) == m_GdbIdMap.end()) + -- m_nMaxId ; + else + return ; + } } private : typedef std::unordered_map< int, GdbObj*> INTPGDBO_UMAP ;