/**
  * Crea una tabella sull'output out, per tutti i generi di sequenze, eseguendo tutti gli algoritmi
  * su array di lunghezze via via crescenti, da step fino a maxLength
  */
 static void makeTable(EnumSet<Algorithm> algorithms, int step, int maxLength, String fileName)
     throws IOException {
   ;
   FileWriter outFile = new FileWriter(fileName, false);
   PrintWriter writer = new PrintWriter(outFile);
   writer.println("sep=;");
   writer.println(
       "Test a on a int array: "
           + getProperty("os.name")
           + " Java "
           + getProperty("java.version"));
   for (SequenceKind kind : SequenceKind.values()) {
     writer.println(kind.toString());
     System.out.println(kind.toString() + "\n");
     for (Algorithm algo : algorithms) writer.print(";" + algo.toString());
     writer.println();
     for (int len = step; len <= maxLength; len += step) {
       runAllAlgorithms(algorithms, kind, writer, len);
     }
     writer.println();
   }
   writer.close();
   System.out.println();
   System.out.println();
 }
  /**
   * Crea una riga della tabella sull'output out, per sequenze di genere kind, eseguendo tutti gli
   * algoritmi algorithms, su un array di lunghezza len
   */
  static void runAllAlgorithms(
      EnumSet<Algorithm> algorithms, SequenceKind kind, PrintWriter out, int len) {
    int maxValue = (kind == SequenceKind.REPEATED_VALUES) ? len / 3 : 9 * len / 10;
    int[] array = naturalRandomArray(len, maxValue);
    if (kind == SequenceKind.ALMOST_SORTED) {
      Arrays.sort(array);
      swap(array, len / 3, 2 * len / 3);
    }

    out.printf("%6d;", len);
    System.out.println(len);
    for (Algorithm algo : algorithms) {
      System.out.println(algo.toString());
      int[] arrayCopy = Arrays.copyOf(array, array.length);
      double time = executionTime(algo, arrayCopy);
      out.printf("%9.2f;", time);
    }
    out.println();
    System.out.println();
  }