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 ;