Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>rowKeySet()</code> is the set of all rows and the <code>columnKeySet()</code> is the set of all columns for the table. However, it may well not be the case that there is a value for every combination of row key and column key. For example, maybe you only calculated a result with a certain <code>RowValue</code> for one of the <code>Data</code> objects. The combination of that <code>RowValue</code> object (row key) and any other <code>Data</code> object (column key) would not map to a <code>Result</code> in that case. It seems likely that you're seeing something like this.</p> <p>To only iterate over the valid mappings, you'd want to do something like this:</p> <pre><code>for (RowValue row : results.rowKeySet()) { // Only iterate over the columns that actually have values for this row for (Data d : results.row(row).keySet()) { System.out.println(results.get(row, d)); } } </code></pre> <p><strong>Edit:</strong></p> <p>From my understanding of what's happening, no <code>null</code> is being set as a value in the table. Rather, something like this is happening:</p> <pre><code>Table&lt;Integer, Integer, String&gt; table = TreeBasedTable.create(); table.put(1, 1, "Foo"); table.put(2, 2, "Bar"); </code></pre> <p>Note that in the entire table, there are rows <code>1</code> and <code>2</code> and columns <code>1</code> and <code>2</code>. However, there is only a value at column <code>1</code> of row <code>1</code> and at column <code>2</code> of row <code>2</code>. So when we iterate through every possible combination of row and column, as you do in your example, we print out the values at row <code>1</code>, column <code>2</code> and at row <code>2</code>, column <code>1</code>, both of which return <code>null</code> since no value was placed at those cells... calling <code>table.contains(1, 2)</code> returns <code>false</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload