package ru.job4j.collections.convert;

import java.util.ArrayList;
import java.util.List;

/**
 * This class convert list of integers to double array and double array to list of integers.
 *
 * @author Kucykh Vasily (mailto:basil135@mail.ru)
 * @version $Id$
 * @since 07.05.2017
 */
public class Convert {

    /**
     * method convert double array to list of integers.
     *
     * @param array is input double array
     * @return List of integers
     */
    public List<Integer> toList(int[][] array) {

        int size = array.length * array[0].length;

        List<Integer> result = new ArrayList<>(size);

        for (int[] row : array) {
            for (int num : row) {
                result.add(num);
            }
        }

        return result;

    }

    /**
     * method convert list of integers to double array with rows number of rows and fill of zeroes free spaces at cols.
     *
     * @param list is input list of integers
     * @param rows is input rows of double array
     * @return double array
     */
    public int[][] toArray(List<Integer> list, int rows) {

        int index = 0;

        int cols = list.size() / rows + 1;

        int[][] result = new int[rows][cols];

        for (int i = 0; i < rows; i++) {

            for (int j = 0; j < cols; j++) {

                if (index < list.size()) {

                    result[i][j] = list.get(index++);

                } else {

                    result[i][j] = 0;

                }

            }

        }

        return  result;

    }

}

@@ -1537,10 +1537,463 @@
 %0A    %7D%0A%0A
+    /**%0A     * method convert list of array of integers to list of integers.%0A     *%0A     * @param list is input list of array of integers%0A     * @return list of integers%0A     */%0A    public List%3CInteger%3E convert(List%3Cint%5B%5D%3E list) %7B%0A%0A        List%3CInteger%3E result = new ArrayList%3C%3E();%0A%0A        for (int%5B%5D array : list) %7B%0A%0A            for (int number : array) %7B%0A%0A                result.add(number);%0A%0A            %7D%0A%0A        %7D%0A%0A        return result;%0A%0A    %7D%0A%0A
 %7D%0A

Refactor Convert.java add new method - convert