private int InsertNewKey(int key)
{
if (check && occupiedCount != keyCount)
{
Kit.CodeBug();
}
if (check && keyCount == 1 << power)
{
Kit.CodeBug();
}
int[] keys = this.keys;
int fraction = key * A;
int index = (int)(((uint)fraction) >> (32 - power));
if (keys[index] != EMPTY)
{
int mask = (1 << power) - 1;
int step = TableLookupStep(fraction, mask, power);
int firstIndex = index;
do
{
if (check && keys[index] == DELETED)
{
Kit.CodeBug();
}
index = (index + step) & mask;
if (check && firstIndex == index)
{
Kit.CodeBug();
}
}
while (keys[index] != EMPTY);
}
keys[index] = key;
++occupiedCount;
++keyCount;
return index;
}