From 914e5a2f6370a2d802d0977b2b89d248936b2adb Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 12 May 2005 05:22:18 +0000 Subject: [PATCH] IPAL8739. Fix ReleaseID() for the case ID == myMaxID && myPoolOfID.empty() --- src/SMDS/SMDS_MeshIDFactory.cxx | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index 74ac917dd..536b2f783 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -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::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::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() ); + } + } } } -- 2.39.2