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