CDependencyGroup: Make use of ranged for
This commit is contained in:
parent
46b9a6eeb3
commit
c11ec0a6fd
|
@ -2,6 +2,7 @@
|
||||||
#define CDEPENDENCYGROUP
|
#define CDEPENDENCYGROUP
|
||||||
|
|
||||||
#include "CResource.h"
|
#include "CResource.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
class CDependencyGroup : public CResource
|
class CDependencyGroup : public CResource
|
||||||
{
|
{
|
||||||
|
@ -21,33 +22,27 @@ public:
|
||||||
mDependencies.push_back(rkID);
|
mDependencies.push_back(rkID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDependency(CResource *pRes)
|
void AddDependency(const CResource* pRes)
|
||||||
{
|
{
|
||||||
if ( pRes && !HasDependency(pRes->ID()) )
|
if (pRes != nullptr && !HasDependency(pRes->ID()))
|
||||||
mDependencies.push_back(pRes->ID());
|
mDependencies.push_back(pRes->ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveDependency(const CAssetID& rkID)
|
void RemoveDependency(const CAssetID& rkID)
|
||||||
{
|
{
|
||||||
for (auto Iter = mDependencies.begin(); Iter != mDependencies.end(); Iter++)
|
const auto it = std::find_if(mDependencies.cbegin(), mDependencies.cend(),
|
||||||
{
|
[&rkID](const auto& entry) { return entry == rkID; });
|
||||||
if (*Iter == rkID)
|
|
||||||
{
|
if (it == mDependencies.cend())
|
||||||
mDependencies.erase(Iter);
|
return;
|
||||||
return;
|
|
||||||
}
|
mDependencies.erase(it);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasDependency(const CAssetID &rkID) const
|
bool HasDependency(const CAssetID& rkID) const
|
||||||
{
|
{
|
||||||
for (uint32 iDep = 0; iDep < mDependencies.size(); iDep++)
|
return std::any_of(mDependencies.cbegin(), mDependencies.cend(),
|
||||||
{
|
[&rkID](const auto& entry) { return entry == rkID; });
|
||||||
if (mDependencies[iDep] == rkID)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CDependencyTree> BuildDependencyTree() const
|
std::unique_ptr<CDependencyTree> BuildDependencyTree() const
|
||||||
|
|
Loading…
Reference in New Issue