last works on xcatb ...

This commit is contained in:
2025-06-20 17:17:11 +03:30
parent 0f4320a44f
commit c74e83b7a8
5 changed files with 903 additions and 80 deletions
+232 -22
View File
@@ -584,10 +584,10 @@ bool IsBoxValid(
*
* @return ( int )
*/
bool FindBoxIndex(
bool FindIndex(
int &index,
XBoxZone &box,
XBoxZone &boxes[] //
XBoxZone &item,
XBoxZone &items[] //
)
{
//
@@ -597,8 +597,8 @@ bool FindBoxIndex(
index = -1;
//
int count = ArraySize(boxes);
result = box.IsValid() &&
int count = ArraySize(items);
result = item.IsValid() &&
IsValidSize(count);
if (!result)
{
@@ -609,10 +609,53 @@ bool FindBoxIndex(
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = boxes[i];
XBoxZone iBox = items[i];
//
bool isSame = box.IsSameAs(iBox);
bool isSame = item.IsSameAs(iBox);
if (isSame)
{
//
index = i;
break;
}
}
//
result = IsValidIndex(index);
//
return result;
}
bool FindIndex(
int &index,
XDirectionShift &item,
XDirectionShift &items[] //
)
{
//
bool result = false;
//
index = -1;
//
int count = ArraySize(items);
result = item.IsValid() &&
IsValidSize(count);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XDirectionShift iItem = items[i];
//
bool isSame = item.IsSameAs(iItem);
if (isSame)
{
//
@@ -631,9 +674,9 @@ bool FindBoxIndex(
/**
* Remove Specified Box from Collection ...
*/
bool RemoveBox(
XBoxZone &box,
XBoxZone &boxes[] //
bool Remove(
XBoxZone &item,
XBoxZone &items[] //
)
{
//
@@ -641,8 +684,8 @@ bool RemoveBox(
//
result =
box.IsValid() &&
HasChild(boxes);
item.IsValid() &&
HasChild(items);
if (!result)
{
return result;
@@ -650,10 +693,10 @@ bool RemoveBox(
//
int idx = -1;
result = FindBoxIndex(
result = FindIndex(
idx,
box,
boxes //
item,
items //
);
if (!result)
{
@@ -662,7 +705,46 @@ bool RemoveBox(
//
result = ArrayRemove(
boxes,
items,
idx,
1 //
);
//
return result;
}
bool Remove(
XDirectionShift &item,
XDirectionShift &items[] //
)
{
//
bool result = false;
//
result =
item.IsValid() &&
HasChild(items);
if (!result)
{
return result;
}
//
int idx = -1;
result = FindIndex(
idx,
item,
items //
);
if (!result)
{
return result;
}
//
result = ArrayRemove(
items,
idx,
1 //
);
@@ -674,7 +756,7 @@ bool RemoveBox(
/**
* Remove Specified Box from Collection ...
*/
int RemoveBoxes(
int Removes(
XBoxZone &items[],
XBoxZone &sources[] //
)
@@ -696,7 +778,54 @@ int RemoveBoxes(
{
//
int idx = -1;
has = FindBoxIndex(
has = FindIndex(
idx,
items[i],
sources //
);
if (has)
{
//
has = ArrayRemove(
sources,
idx,
1 //
);
//
if (has)
{
result++;
}
}
}
//
return result;
}
int Removes(
XDirectionShift &items[],
XDirectionShift &sources[] //
)
{
//
int result = 0;
//
bool has = HasChild(items) &&
HasChild(sources);
if (!has)
{
return result;
}
//
int count = ArraySize(items);
for (int i = 0; i < count; i++)
{
//
int idx = -1;
has = FindIndex(
idx,
items[i],
sources //
@@ -730,7 +859,7 @@ int RemoveBoxes(
*
* @return ( bool )
*/
bool AddBoxIfNotExists(
bool AddIfNotExists(
XBoxZone &item,
XBoxZone &sources[] //
)
@@ -749,7 +878,46 @@ bool AddBoxIfNotExists(
//
// Check Item Exists or not ...
int idx = -1;
bool isExists = FindBoxIndex(
bool isExists = FindIndex(
idx,
item,
sources //
);
result = !isExists;
if (!result)
{
return result;
}
//
AddRef(
item,
sources //;
);
//
return result;
}
bool AddIfNotExists(
XDirectionShift &item,
XDirectionShift &sources[] //
)
{
//
bool result = false;
//
// Validate Args ...
result = item.IsValid();
if (!result)
{
return result;
}
//
// Check Item Exists or not ...
int idx = -1;
bool isExists = FindIndex(
idx,
item,
sources //
@@ -778,7 +946,7 @@ bool AddBoxIfNotExists(
*
* @return ( int )
*/
int AddBoxIfNotExists(
int AddIfNotExists(
XBoxZone &items[],
XBoxZone &sources[] //
)
@@ -801,7 +969,7 @@ int AddBoxIfNotExists(
for (int i = 0; i < count; i++)
{
//
has = AddBoxIfNotExists(
has = AddIfNotExists(
items[i],
sources //
);
@@ -816,6 +984,48 @@ int AddBoxIfNotExists(
//
return result;
}
int AddIfNotExists(
XDirectionShift &items[],
XDirectionShift &sources[] //
)
{
//
int result = 0;
//
bool has = HasChild(items);
if (!has)
{
return result;
}
//
int before = ArraySize(sources);
//
int count = ArraySize(items);
for (int i = 0; i < count; i++)
{
//
has = AddIfNotExists(
items[i],
sources //
);
}
//
int after = ArraySize(sources);
//
result = after > before;
//
return result;
}
//
//
//
//
void SortBoxes(
+3 -3
View File
@@ -310,7 +310,7 @@ struct XBoxZone
/**
* Retrieve Box Applied Price ...
*
*
* @return ( double )
*/
double GetDirectionalPrice()
@@ -336,7 +336,7 @@ struct XBoxZone
/**
* Retrieve Box Breaked Price ...
*
*
* @return ( double )
*/
double GetInDirectionalPrice()
@@ -722,4 +722,4 @@ struct XDirectionShift
}
};
//
//