public double[][] toMatrix(List<K1> firstKeys, List<K2> secondKeys) {
    double[][] counts = new double[firstKeys.size()][secondKeys.size()];
    for (int i = 0; i < firstKeys.size(); i++) {
      for (int j = 0; j < secondKeys.size(); j++) {
        counts[i][j] = getCount(firstKeys.get(i), secondKeys.get(j));
      }
    }
    return counts;
  }
public double [ ] [ ] toMatrix ( List < K1 > firstKeys , List < K2 > secondKeys ) { double [ ] [ ] counts = new double [ firstKeys . size ( ) ] [ secondKeys . size ( ) ] ; for ( int i = 0 ; i < firstKeys . size ( ) ; i ++ ) { for ( int j = 0 ; j < secondKeys . size ( ) ; j ++ ) { counts [ i ] [ j ] = getCount ( firstKeys . get ( i ) , secondKeys . get ( j ) ) ; } } return counts ; }
Given an ordering of the first (row) and second (column) keys, will produce
a double matrix.