in csharp/src/Containers/SortedSqrtDecomposition.cs [244:298]
public bool Remove(Type x)
{
bool delete = false;
if (needRebuild)
{
RebuildSqrt();
}
for (int j = 1; j < numberOfBlocks; ++j)
{
if (comparator.Compare(dataInBegin[j], x) > 0)
{
for (int k = (len * (j - 1) << 1); k < endOfBlock[j - 1]; ++k)
{
if (comparator.Compare(data[k], x) == 0)
{
if (k == (len * (j - 1) << 1)) dataInBegin[j - 1] = data[k + 1];
for (int l = k; l < endOfBlock[j - 1] - 1; l++)
{
data[l] = data[l + 1];
}
endOfBlock[j - 1]--;
size--;
if (endOfBlock[j - 1] <= (len * (j - 1) << 1))
{
RebuildSqrt();
};
return true;
}
}
return false;
}
}
if (!delete)
{
for (int k = (len * (numberOfBlocks - 1) << 1); k < endOfBlock[numberOfBlocks - 1]; k++)
{
if (comparator.Compare(data[k], x) == 0)
{
if (k == (len * (numberOfBlocks - 1)) << 1) dataInBegin[numberOfBlocks - 1] = data[k + 1];
for (int l = k; l < endOfBlock[numberOfBlocks - 1] - 1; l++)
{
data[l] = data[l + 1];
}
endOfBlock[numberOfBlocks - 1]--;
size--;
if (endOfBlock[numberOfBlocks - 1] <= (len * (numberOfBlocks - 1) << 1))
{
RebuildSqrt();
}
return true;
}
}
}
return false;
}