ArrayFeatureVector extends FeatureVector { public double[] toArray() { double[] result = new double[features.size()]; int index = 0; for (Double d : features) { result[index] = d; index += 1; } return result; } ArrayFeatureVector(); double get(int index); java.util.Iterator<Entry> iterator(); void set(int index, double value); double[] toArray();  }
@Test public void toArray() { double[] a = fv2.toArray(); double[] expected = new double[] { 0, 4.5, 0, 0, 0, 7.1, 13, 0, 0, 0, 2.3 }; for (int i = 0; i < a.length; i++) { if (i < expected.length) assertEquals(a[i], expected[i], delta); else assertEquals(a[i], 0.0, 0.0); } }