mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50: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;
|
if (myPoolOfID.empty()) return ++myMaxID;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ID = myPoolOfID.top();
|
set<int>::iterator i = myPoolOfID.begin();
|
||||||
myPoolOfID.pop();
|
int ID = *i;//myPoolOfID.top();
|
||||||
|
myPoolOfID.erase( i );//myPoolOfID.pop();
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,5 +57,16 @@ int SMDS_MeshIDFactory::GetFreeID()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMDS_MeshIDFactory::ReleaseID(const int ID)
|
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
|
#define _SMDS_MeshIDFactory_HeaderFile
|
||||||
|
|
||||||
#include "SMDS_MeshObject.hxx"
|
#include "SMDS_MeshObject.hxx"
|
||||||
#include <stack>
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
class SMDS_MeshIDFactory:public SMDS_MeshObject
|
class SMDS_MeshIDFactory:public SMDS_MeshObject
|
||||||
@ -40,7 +40,7 @@ class SMDS_MeshIDFactory:public SMDS_MeshObject
|
|||||||
protected:
|
protected:
|
||||||
SMDS_MeshIDFactory();
|
SMDS_MeshIDFactory();
|
||||||
int myMaxID;
|
int myMaxID;
|
||||||
std::stack<int> myPoolOfID;
|
std::set<int> myPoolOfID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user