Example usage for com.google.common.collect ArrayTable rowKeyList

List of usage examples for com.google.common.collect ArrayTable rowKeyList

Introduction

In this page you can find the example usage for com.google.common.collect ArrayTable rowKeyList.

Prototype

public ImmutableList<R> rowKeyList() 

Source Link

Document

Returns, as an immutable list, the row keys provided when the table was constructed, including those that are mapped to null values only.

Usage

From source file:eu.itesla_project.sampling.util.Utils.java

public static double[][] histoDataAsDoubleMatrixNew(ArrayTable<Integer, String, Float> hdTable) {
    int rowsSize = hdTable.rowKeySet().size();
    int colsSize = hdTable.columnKeySet().size();
    double[][] matFinal = new double[rowsSize][colsSize];
    int i = 0;//from   w ww  .  j a v a  2s. c o  m
    for (Integer rowKey : hdTable.rowKeyList()) {
        int j = 0;
        for (String colkey : hdTable.columnKeyList()) {
            Float v = hdTable.get(rowKey, colkey);
            matFinal[i][j] = ((v != null) && (v.isNaN() == false)) ? v : 0.0f;
            j = j + 1;
        }
        i = i + 1;
    }
    return matFinal;
}

From source file:eu.itesla_project.mcla.forecast_errors.FEAMatFileWriter.java

private MLDouble histoDataAsMLDouble(String name, ArrayTable<Integer, String, Float> histoData) {
    int rowsSize = histoData.rowKeySet().size();
    int colsSize = histoData.columnKeySet().size();
    MLDouble mlDouble = new MLDouble(name, new int[] { rowsSize, colsSize });
    int i = 0;/*from w w w .  j a va2 s.co  m*/
    for (Integer rowKey : histoData.rowKeyList()) {
        int j = 0;
        for (String colkey : histoData.columnKeyList()) {
            Float v = histoData.get(rowKey, colkey);
            mlDouble.set(new Double(v), i, j);
            j++;
        }
        i++;
    }
    return mlDouble;
}

From source file:org.dishevelled.analysis.AnalysisUtils.java

/**
 * Convert the specified array table to a bit matrix.  Values in the returned bit
 * matrix will be set to true where a value exists in the specified array table
 * accepted by the specified predicate.// w  ww  .ja  v a  2  s.c o m
 *
 * @param <N> array table row and column key type
 * @param <E> array table value type
 * @param table array table to convert, must not be null
 * @param predicate array table value predicate, must not be null
 * @return the specified array table converted to a bit matrix
 */
public static <N, E> BitMatrix2D toBitMatrix(final ArrayTable<N, N, E> table,
        final UnaryPredicate<E> predicate) {
    if (table == null) {
        throw new IllegalArgumentException("table must not be null");
    }
    if (predicate == null) {
        throw new IllegalArgumentException("predicate must not be null");
    }
    int rows = table.rowKeyList().size();
    int columns = table.columnKeyList().size();
    BitMatrix2D bitMatrix = new BitMatrix2D(rows, columns);
    for (int row = 0; row < rows; row++) {
        for (int column = 0; column < columns; column++) {
            bitMatrix.set(row, column, predicate.test(table.at(row, column)));
        }
    }
    return bitMatrix;
}