/** Reads the examples into memory and permutes the order. Removes all old data rows first. */
 public void readExamples(DataRowReader i, boolean permute, Random random) {
   dataList.clear();
   while (i.hasNext()) {
     if (permute) {
       if (random == null) {
         random = new Random();
       }
       int index = random.nextInt(dataList.size() + 1);
       dataList.add(index, i.next());
     } else {
       dataList.add(i.next());
     }
   }
 }
 public static MemoryExampleTable createCompleteCopy(ExampleTable oldTable) {
   MemoryExampleTable table = new MemoryExampleTable(Arrays.asList(oldTable.getAttributes()));
   DataRowReader reader = oldTable.getDataRowReader();
   while (reader.hasNext()) {
     DataRow dataRow = reader.next();
     double[] newDataRowData = new double[oldTable.getNumberOfAttributes()];
     for (int a = 0; a < oldTable.getNumberOfAttributes(); a++) {
       Attribute attribute = oldTable.getAttribute(a);
       if (attribute != null) {
         newDataRowData[a] = dataRow.get(attribute);
       } else {
         newDataRowData[a] = Double.NaN;
       }
     }
     table.addDataRow(new DoubleArrayDataRow(newDataRowData));
   }
   return table;
 }