### Question:
TopNTruncator implements VectorTruncator, Serializable { @Override public Long2DoubleMap truncate(Long2DoubleMap v) { TopNLong2DoubleAccumulator accumulator = new TopNLong2DoubleAccumulator(n); for (Long2DoubleMap.Entry e : Vectors.fastEntries(v)) { double x = e.getDoubleValue(); if (threshold == null || threshold.retain(x)) { accumulator.put(e.getLongKey(), x); } } return accumulator.finishMap(); } TopNTruncator(int n, Threshold threshold);  TopNTruncator(int n); @Override Long2DoubleMap truncate(Long2DoubleMap v);  }### Answer:
@Test public void testSimpleTruncate() { long[] keys = {1, 2, 3, 4, 5}; double[] values = {1.0, 2.0, 3.0, 4.0, 5.0}; Long2DoubleSortedArrayMap v = Long2DoubleSortedArrayMap.wrapUnsorted(keys, values); VectorTruncator truncator = new TopNTruncator(3, null); Long2DoubleMap v2 = truncator.truncate(v); long i = 3; for (Long2DoubleMap.Entry e: v2.long2DoubleEntrySet()) { assertThat(e.getLongKey(), equalTo(i)); assertThat(e.getDoubleValue(), closeTo(i, EPSILON)); i++; } assertThat(i, equalTo(6L)); }