Last Works on XSDT Pivot Detector ...
This commit is contained in:
@@ -3482,6 +3482,74 @@ int FillNotExists(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int FillNotExists(
|
||||
T &dest[],
|
||||
T &source[],
|
||||
bool forceClean = false,
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
||||
int maxAllowed = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
if (forceClean)
|
||||
{
|
||||
XClean(dest);
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
maxAllowed = NormalizeInt(maxAllowed, 0);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has =
|
||||
source[i].IsValid() &&
|
||||
(!HasDirection(forDir) || forDir == source[i].dir);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
has = AddIfNotExists(source[i], dest);
|
||||
if (has)
|
||||
{
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Cleanup Collection
|
||||
// if Max Reached ...
|
||||
if (maxAllowed > 0)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
dest,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user