Java 如何计算完成程序所需步骤的输出

Java 如何计算完成程序所需步骤的输出,java,random,hash,Java,Random,Hash,嗨,我有这个程序,我想计算和打印的总步骤,需要完成程序时,我运行它10次。(计算控制台线路总数) 欢迎您提供任何建议 哈希表的代码: public class HashFunction { String[] theArray; int arraySize; int itemsInArray = 0; int K = 0; /** * * @param args */ public static void main(String[] args) { HashFunction

嗨,我有这个程序,我想计算和打印的总步骤,需要完成程序时,我运行它10次。(计算控制台线路总数)

欢迎您提供任何建议

哈希表的代码:

public class HashFunction {

String[] theArray;
int arraySize;
int itemsInArray = 0;
    int K = 0;

/**
 *
 * @param args
 */
public static void main(String[] args) {


HashFunction theFunc = new HashFunction(101);

String[] elementsToAdd2 = new String[101];

for (int i = 0; i <= 100; i++) {
elementsToAdd2[i] = Integer.toString(RandomNumbers.getRandomNumberInRange(0, 15024267));
}



    theFunc.hashFunction2(elementsToAdd2, theFunc.theArray);

}


public void hashFunction2(String[] stringsForArray, String[] theArray) {

    for (int n = 0; n < stringsForArray.length; n++) {

        String newElementVal = stringsForArray[n];

        // Create an index to store the value in by taking
        // the modulus

        int arrayIndex = Integer.parseInt(newElementVal) % 101;

        System.out.println("P" + arrayIndex + " " + "I" + newElementVal + "@" + arrayIndex );

        // Cycle through the array until we find an empty space

        while (theArray[arrayIndex] != "-1") {

            ++arrayIndex;

            System.out.println( "P" + arrayIndex);

            // If we get to the end of the bucket go back to index 0

            arrayIndex %= arraySize;

        }

        theArray[arrayIndex] = newElementVal;

    }

}

HashFunction(int size) {

    arraySize = size;

    theArray = new String[size];

    Arrays.fill(theArray, "-1");

}
公共类哈希函数{
字符串[]数组;
内部阵列化;
int itemsInArray=0;
int K=0;
/**
*
*@param args
*/
公共静态void main(字符串[]args){
HashFunction theFunc=新的HashFunction(101);
String[]elementsToAdd2=新字符串[101];

对于(int i=0;i)您如何准确定义“步骤”?总步骤是什么意思?我的意思是计数,将随机生成的键逐个插入初始为空的101 bucket哈希表所需的操作跟踪请给出示例。您能识别定义步骤的代码行吗?您能为每个步骤命名所有代码行吗?我想计算哈希表操作,例如这里的实例
P19I9526036@19P20 P21P2I11651766@2
我打印了5个操作我想打印一些代码“需要的步骤数:5”
public class RunTenTimes
    {
public static void main(String[] args)
  {
      for(int i=1; i<=10; i++)
          HashFunction.main(args); 
  }
}