X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshIDFactory.cxx;h=989e42be33d85bb5244680f546aefd49547a9d8f;hb=c46bd4f9bb602f9863c817bcd622b1b70d5af1e9;hp=db5df4222ce3d2f3fd5661f4ee9b5d621b8e0d6b;hpb=c3bf92bd87b770fd81631a3853f7f5bb1ac6a4e8;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index db5df4222..989e42be3 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -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() ); + } + } + } }