//支持优先队列的最大值和最小值删除,aType = 0是删除最小值 aType = 1是删除最大值
void STdeleteMinAndMax(int aType)
{
STfilterData();
int ret = 0;
int i = 0;
int n = STcount();
int tempIndex = 0;
int minAndMax = g_cache[0];
for (int j = 0;j < n;++j)
{
tempIndex = g_cache[0];
for (i = 0;i < n-1;++i)
{
g_cache[i] = g_cache[i+1];
}
if (!aType)
{
if (minAndMax > tempIndex)
{
minAndMax = tempIndex;
}
}
else if (aType == 1)
{
if (minAndMax < tempIndex)
{
minAndMax = tempIndex;
}
}
g_cache[i] = tempIndex;
}
for (int j = 0;j < n;++j)
{
tempIndex = g_cache[0];
for (i = 0;i < n-1;++i)
{
g_cache[i] = g_cache[i+1];
}
if (minAndMax == tempIndex)
{
ret += 1;
g_cache[i] = 0;
break;
}
g_cache[i] = tempIndex;
}
if (!ret)
{
printf("STdeleteMinAndMax failed\n");
}
else
{
printf("STdeleteMinAndMax successfull\n");
}
indexX -=ret;
}