IPAL8739. Fix ReleaseID() for the case ID == myMaxID && myPoolOfID.empty()

This commit is contained in:
eap 2005-05-12 05:22:18 +00:00
parent f5fcc431a4
commit 914e5a2f63

View File

@ -57,16 +57,27 @@ int SMDS_MeshIDFactory::GetFreeID()
//=======================================================================
void SMDS_MeshIDFactory::ReleaseID(const int ID)
{
if (ID > 0 && ID < myMaxID) myPoolOfID./*push*/insert(ID);
if (ID > 0 && ID == myMaxID ) {
set<int>::iterator i = --myPoolOfID.end();
while ( i != myPoolOfID.begin() )
if ( --myMaxID != *(--i) )
break;
if ( myMaxID == *i )
--myMaxID; // begin of myPoolOfID reached
else
++i;
myPoolOfID.erase( i, myPoolOfID.end() );
if ( ID > 0 )
{
if ( ID < myMaxID )
{
myPoolOfID.insert(ID);
}
else if ( ID == myMaxID )
{
--myMaxID;
if ( !myPoolOfID.empty() ) // assure that myMaxID is not in myPoolOfID
{
set<int>::iterator i = --myPoolOfID.end();
while ( i != myPoolOfID.begin() && myMaxID == *i ) {
--myMaxID; --i;
}
if ( myMaxID == *i )
--myMaxID; // begin of myPoolOfID reached
else
++i;
myPoolOfID.erase( i, myPoolOfID.end() );
}
}
}
}