### Question:
ThresholdTruncator implements VectorTruncator, Serializable { @Override public Long2DoubleMap truncate(Long2DoubleMap v) { Long2DoubleMap res = new Long2DoubleOpenHashMap(v.size()); for (Long2DoubleMap.Entry e: Vectors.fastEntries(v)) { if (threshold.retain(e.getDoubleValue())) { res.put(e.getLongKey(), e.getDoubleValue()); } } return res; } @Inject  ThresholdTruncator(Threshold threshold); @Override Long2DoubleMap truncate(Long2DoubleMap v);  }### Answer:
@Test public void testTruncate() { long[] keys = {1, 2, 3, 4}; double[] values = {1.0, 2.0, 3.0, 4.0}; Long2DoubleSortedArrayMap v = Long2DoubleSortedArrayMap.wrapUnsorted(keys, values); VectorTruncator truncator = new ThresholdTruncator(new RealThreshold(3.5)); Long2DoubleMap v2 = truncator.truncate(v); int numSeen = 0; for (Long2DoubleMap.Entry e: v2.long2DoubleEntrySet()) { assertThat(e.getLongKey(), equalTo(4L)); assertThat(e.getDoubleValue(), closeTo(4.0, EPSILON)); numSeen++; } assertThat(numSeen, equalTo(1)); }