X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FSMDS%2FSMDS_MeshIDFactory.cxx;h=536b2f7835974448c9f8af4f2dc8a1297508e09b;hb=bf15ad4ece61167d57bf874729521b6a8391a728;hp=a68ae5ad0325a37bfe530818c2349cf123f77c17;hpb=13b8c20dfc9f5bedf2dd4699ac1e05a8d4227791;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index a68ae5ad0..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 < 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() ); + } + } + } }