Java Thread Callable copyFromList(final List list, final double[][] data, final int cols)

Here you can find the source of copyFromList(final List list, final double[][] data, final int cols)

Description

copy From List

License

Open Source License

Declaration

public static Callable copyFromList(final List list, final double[][] data, final int cols) 

Method Source Code


//package com.java2s;
import java.util.concurrent.*;
import java.util.List;

public class Main {
    public static Callable copyFromList(final List list, final double[][] data, final int cols) {
        Callable c = new Callable() {
            public Object call() throws Exception {
                int s = list.size();
                double[] rowData = null;
                int row = -1;
                int col = 0;
                for (int i = 0; i < s; i++) {
                    if (i % cols == 0) {
                        row++;//from   w w  w.j  av  a2s . c o  m
                        rowData = new double[cols];
                        col = 0;
                        data[row] = rowData;
                    }
                    Object o = list.get(i);
                    rowData[col] = (Double) o;
                    col++;

                }
                return data;
            }
        };
        return c;
    }
}

Related

  1. callableListCreator()
  2. callConditionAndReturnResult(Callable condition)
  3. callInLoader(Callable body, ClassLoader loader)
  4. callInLocale(Locale locale, Callable task)
  5. callWithSystemProperty(String name, String value, Callable callee)
  6. copyInto(final List list, final double[] data)
  7. executeLocally(Callable task)
  8. executeUntilNonNullOrTimeout(final long timeoutMs, final long timeBetweenPollsMs, final Callable callable)
  9. executeWithClassLoader(ClassLoader classLoader, Callable callable)