mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 09:20:34 +05:00
IPAL8739. Replace stack with set: assure increasing order or released IDs and clearing of ID pool when possible
This commit is contained in:
parent
5e37ea4dc8
commit
f5fcc431a4
@ -44,8 +44,9 @@ int SMDS_MeshIDFactory::GetFreeID()
|
||||
if (myPoolOfID.empty()) return ++myMaxID;
|
||||
else
|
||||
{
|
||||
int ID = myPoolOfID.top();
|
||||
myPoolOfID.pop();
|
||||
set<int>::iterator i = myPoolOfID.begin();
|
||||
int ID = *i;//myPoolOfID.top();
|
||||
myPoolOfID.erase( i );//myPoolOfID.pop();
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
@ -56,5 +57,16 @@ int SMDS_MeshIDFactory::GetFreeID()
|
||||
//=======================================================================
|
||||
void SMDS_MeshIDFactory::ReleaseID(const int ID)
|
||||
{
|
||||
if (ID > 0 && ID < myMaxID) myPoolOfID.push(ID);
|
||||
if (ID > 0 && ID < myMaxID) myPoolOfID./*push*/insert(ID);
|
||||
if (ID > 0 && ID == myMaxID ) {
|
||||
set<int>::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() );
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define _SMDS_MeshIDFactory_HeaderFile
|
||||
|
||||
#include "SMDS_MeshObject.hxx"
|
||||
#include <stack>
|
||||
#include <set>
|
||||
|
||||
|
||||
class SMDS_MeshIDFactory:public SMDS_MeshObject
|
||||
@ -40,7 +40,7 @@ class SMDS_MeshIDFactory:public SMDS_MeshObject
|
||||
protected:
|
||||
SMDS_MeshIDFactory();
|
||||
int myMaxID;
|
||||
std::stack<int> myPoolOfID;
|
||||
std::set<int> myPoolOfID;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user