Java Utililty Methods List Transpose

List of utility methods to do List Transpose

Description

The list of methods to do List Transpose are organized into topic(s).

Method

List>transpose(List> input)
transpose
Object[][] matrix = new Object[input.size()][];
int max = 0;
for (Iterator<List<?>> i = input.iterator(); i.hasNext();) {
    List<?> a = i.next();
    max = Math.max(max, a.size());
for (int i = 0; i < input.size(); i++) {
    List<?> a = input.get(i);
...
List>transpose(List> matrix)
transpose
List<List<Double>> transposed = new ArrayList<List<Double>>(matrix.get(0).size());
final int origRows = matrix.get(0).size();
for (int colIndex = 0; colIndex < origRows; colIndex++) {
    transposed.add(new ArrayList<Double>(matrix.size()));
for (final List<Double> origColumn : matrix) {
    for (int rowIndex = 0; rowIndex < origColumn.size(); rowIndex++) {
        transposed.get(rowIndex).add(origColumn.get(rowIndex));
...
List>transpose(List> matrix)
Transposes a given matrix represented as a list of lists.
List<List<T>> transposedMatrix = new ArrayList<List<T>>();
int nbOfColumns = -1;
int nbOfRows = -1;
if (matrix != null && !matrix.isEmpty()) {
    nbOfRows = matrix.size();
    for (List<T> row : matrix) {
        if (nbOfColumns == -1)
            nbOfColumns = row.size();
...
List>transpose(List> table)
transpose
List<List<T>> ret = new ArrayList<List<T>>();
final int N = table.get(0).size();
for (int i = 0; i < N; i++) {
    List<T> col = new ArrayList<T>();
    for (List<T> row : table) {
        col.add(row.get(i));
    ret.add(col);
...