所以我可以通过将索引设置为c [h]离开i来查看具有参数的列表,但我不确定如何在没有参数的情况下执行此操作。没有这个索引,我将如何进行迭代?省略和打印。
{
private int howmany;
private int[] c;
int counter = 0;
public Intcoll7()
{
c = new int[23];
howmany = 0;
}
public Intcoll7(int i)
{
double z = (i % 23);
int y = (int) z;
while (!isprime(y))
{
y--;
}
howmany = 0;
}
public void insert(int i)
{
int h = i % 23;
int H = h;
if (c[h] == 0)
{
c[h] = i;
howmany++;
} else if (c[h] == i) ; else
{
if (h < c.length - 1)
{
h++;
} else
{
h = 0; // why does h = 0?
}
while ((h != H) && (c[h] != 0) && (c[h] != i))
{
if (h < c.length - 1)
{
h++;
} else
{
h = 0;
}
}
if (h != H)
{
if (c[h] == 0)
{
c[h] = i;
howmany++;
}
} else
{
System.out.println("Table Full");
System.exit(1);
}
}
}
public boolean belongs(int i)
{
//address
int h = i % 23;
int H = h; // what
if (c[h] == 0)
{
return false;
} if (c[h] == H)
{
return true;
}
else
{
return false;
}
}
public void omit(int i)
{
int h = i % 23;
if (c[h] == i)
{
if (counter == 3)
{
//crate new array
}
c[h] = i * (-1);
counter++;
}
}
private static boolean isprime(int n)
{
int i = 2;
boolean result = true;
while ((i <= n / 2) && result)
{
if (n % i == 0)
{
result = false;
} else
{
i++;
}
}
return (result);
}
public void print()
{
System.out.println();
//int x = c[z];
//System.out.println(x);
}
}