public double get(int col, int row) { if (row >= rows.size()) { return 0; } else { DoubleList cols = (DoubleList) rows.get(row); if (col >= cols.size()) return 0; else return cols.get(col); } }
public void testSingletonDoubleList() { DoubleList list = DoubleCollections.singletonDoubleList((double) 17); assertEquals(1, list.size()); assertEquals(17, list.get(0), (double) 0); try { list.add((double) 18); fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { // expected } }
private void resizeCols(int row, int col) { DoubleList cols = (DoubleList) rows.get(row); while (cols.size() <= col) cols.add(0); }