X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshIDFactory.cxx;h=536b2f7835974448c9f8af4f2dc8a1297508e09b;hb=deb5f024f2af09293ce204616d618aeda01c965a;hp=96314592de10318b74ff108f3e67fdae9a8ca67a;hpb=e4737e85f0da6d3f90fd08f6be1c2825195fe16f;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index 96314592d..536b2f783 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -44,8 +44,9 @@ int SMDS_MeshIDFactory::GetFreeID() if (myPoolOfID.empty()) return ++myMaxID; else { - int ID = myPoolOfID.top(); - myPoolOfID.pop(); + set::iterator i = myPoolOfID.begin(); + int ID = *i;//myPoolOfID.top(); + myPoolOfID.erase( i );//myPoolOfID.pop(); return ID; } } @@ -56,5 +57,27 @@ int SMDS_MeshIDFactory::GetFreeID() //======================================================================= void SMDS_MeshIDFactory::ReleaseID(const int ID) { - if (ID > 0 && ID < myMaxID) myPoolOfID.push(ID); + 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() ); + } + } + } }