Java List Concatenate ConcatenateInt(List arrays)

Here you can find the source of ConcatenateInt(List arrays)

Description

Concatenate all the arrays in the list into a vector.

License

BSD License

Parameter

Parameter Description
arrays List of arrays.

Return

Vector.

Declaration

public static int[] ConcatenateInt(List<int[]> arrays) 

Method Source Code

//package com.java2s;
// under the BSD license. The original license terms are given below:

import java.util.List;

public class Main {
    /**//from w ww  . java 2 s.c o  m
     * Concatenate all the arrays in the list into a vector.
     * @param arrays List of arrays.
     * @return Vector.
     */
    public static int[] ConcatenateInt(List<int[]> arrays) {

        int size = 0;
        for (int i = 0; i < arrays.size(); i++) {
            size += arrays.get(i).length;
        }

        int[] all = new int[size];
        int idx = 0;

        for (int i = 0; i < arrays.size(); i++) {
            int[] v = arrays.get(i);
            for (int j = 0; j < v.length; j++) {
                all[idx++] = v[i];
            }
        }

        return all;
    }
}

Related

  1. concatenate(List a, List b)
  2. concatenate(List contents, String separator)
  3. concatenate(List... lists)
  4. concatenate(String[] selectors, List lessExtends)
  5. concatenateFileContent(List fileContents)
  6. concatenateList(List values)
  7. concatenateList(List list, String separator)
  8. concatenateListOfStrings(List list, String separator)
  9. concatenateLists(List... lists)