Fel'Unh Ikk
❔ Filtering out worse states from states array
that's a problem because imagine 2 states, with all fields set to 0.
first state has Progress of 100 and second state has Quality of 200.
I have to keep both states as none of them are worse than each other
24 replies
❔ Filtering out worse states from states array
the method I use now includes some other unimportant code, but here it is
public static int RemoveWorseStates_TwoPointers(CESPacked[] packedArray, ref int length)
{
int right = length - 1;
int removedCount = 0;
for (int i = 0; i < right; i++)
{
bool isWorse = false;
for (int j = i + 1; j <= right; j++)
{
if (packedArray[i].AllWorseOrEqual(packedArray[j]))
{
isWorse = true;
break;
}
}
if (isWorse)
{
CESPacked temp = packedArray[i];
packedArray[i] = packedArray[right];
packedArray[right] = temp;
right--;
removedCount++;
i--;
}
}
length -= removedCount;
int to = length + removedCount;
for (int i = length; i < to; i++)
{
if (!packedArray[i].IsDisposed)
{
packedArray[i].Dispose();
}
else
Debugger.Break();
}
return removedCount;
}
24 replies