X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshIDFactory.cxx;h=536b2f7835974448c9f8af4f2dc8a1297508e09b;hb=80b2ef84c3197c4159cd6b82cc6a476853e76022;hp=db5df4222ce3d2f3fd5661f4ee9b5d621b8e0d6b;hpb=c3bf92bd87b770fd81631a3853f7f5bb1ac6a4e8;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index db5df4222..536b2f783 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -28,6 +28,8 @@ #include "SMDS_MeshIDFactory.hxx" +using namespace std; + //======================================================================= //function : SMDS_MeshIDFactory //purpose : @@ -42,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; } } @@ -54,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() ); + } + } + } }