List of usage examples for com.google.common.collect ArrayTable at
public V at(int rowIndex, int columnIndex)
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 . j a v a 2s.com * * @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; }