SparseFeatureVector extends FeatureVector { public void set(int index, double value) throws InvalidFeatureVectorValueException { if (Double.isInfinite(value) || Double.isNaN(value)) throw new InvalidFeatureVectorValueException(index, value); if (value != 0.0) this.values.put(index, value); else { if (this.values.containsKey(index)) this.values.remove(index); } } SparseFeatureVector();  SparseFeatureVector(FeatureVector fv); double get(int index); java.util.Iterator<Entry> iterator(); void set(int index, double value); double innerProduct(FeatureVector other);  }
@Test public void testEquals() throws Throwable { FeatureVector fv = new SparseFeatureVector(); fv.set(1, 4.5); fv.set(5, 7.1); fv.set(6, 13); assertFalse(fv.equals(fv2)); fv.set(10, 2.3); assertTrue(fv.equals(fv2)); assertEquals(fv.hashCode(), fv2.hashCode()); fv.set(11, 7); assertFalse(fv.equals(fv2)); fv.set(5, 7.2); assertFalse(fv.equals(fv2)); assertFalse(fv.equals(new Integer(5))); }