public int size() {
        return data.size();
    }
@Test
    public void testDense() {
        MockOutputFactory mockFactory = new MockOutputFactory();
        MockDataSourceProvenance mockProvenance = new MockDataSourceProvenance();
        MockOutput mockOutput = new MockOutput("test");

        MutableDataset<MockOutput> dataset = new MutableDataset<>(mockProvenance, mockFactory);

        // Empty datasets are dense
        assertTrue(dataset.isDense());

        ArrayExample<MockOutput> first = new ArrayExample<>(mockOutput,new String[]{"a","b","c"},new double[]{1,1,1});
        ArrayExample<MockOutput> second = new ArrayExample<>(mockOutput,new String[]{"a","b","c","d"},new double[]{1,1,1,1});
        ArrayExample<MockOutput> third = new ArrayExample<>(mockOutput,new String[]{"a","b","c"},new double[]{3,3,3});
        ArrayExample<MockOutput> fourth = new ArrayExample<>(mockOutput,new String[]{"b","c"},new double[]{1,1});

        dataset.add(first);
        MutableDataset<MockOutput> deser = (MutableDataset<MockOutput>) Helpers.testDatasetSerialization(dataset);

        // This example is dense
        assertTrue(dataset.isDense());
        assertTrue(deser.isDense());

        dataset.add(second);
        deser = (MutableDataset<MockOutput>) Helpers.testDatasetSerialization(dataset);

        // This example is dense, but it makes the previous one not dense as it adds a new feature
        assertFalse(dataset.isDense());
        assertFalse(deser.isDense());

        // flush out the previous test
        dataset.clear();

        dataset.add(first);
        dataset.add(third);

        // These examples are both dense
        assertTrue(dataset.isDense());

        // flush out old test
        dataset.clear();

        // Add all the examples, making it sparse
        dataset.add(first);
        dataset.add(second);
        dataset.add(third);
        dataset.add(fourth);

        // Should be sparse
        assertFalse(dataset.isDense());

        // Densify it
        dataset.densify();

        // Now it should be dense
        assertTrue(dataset.isDense());

        ArrayExample<MockOutput> fifth = new ArrayExample<>(mockOutput,new String[]{"a","b","c","d","e"},new double[]{1,1,1,1,1});

        // Makes the previous examples sparse
        dataset.add(fifth);
        assertFalse(dataset.isDense());

        dataset.densify();

        assertTrue(dataset.isDense());

        for (Example<MockOutput> e : dataset) {
            assertEquals(5,e.size());
        }

        Helpers.testDatasetSerialization(dataset);
    }