class SparseVector extends Vector {

    @Override
    public double get(int i) {
        int pos = Arrays.binarySearch(indices, i);
        if (pos >= 0) {
            return values[pos];
        }
        return 0.;
    }

}

class SparseVectorTest {

    private static final double TOL;
    private SparseVector v1;
    private SparseVector v2;

    @Test
    public void testGet() throws Exception {

        Assert.assertEquals(v1.get(5), 2.0, TOL);
        Assert.assertEquals(v1.get(6), 0.0, TOL);
    }

}