/** * Finish accumulating and return the accumulated results. * * When this method is called, the accumulator is reset and can be used to accumulate a fresh set of results. * * @return The accumulated results, in nonincreasing order of score. */ public ResultList finish() { return Results.newResultList(accum.finish()); }
public ResultMap finishMap() { return Results.newResultMap(accum.finish()); } }
@Test public void testEmptyLimitedAccum() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(5); assertThat(acc.finish(), hasSize(0)); }
@Test public void testEmptyUnlimitedAccum() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(-1); assertThat(acc.finish(), hasSize(0)); }
@Test public void testUnlimitedAddOne() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(-1); acc.add("foo"); List<String> res = acc.finish(); assertThat(res, hasSize(1)); assertThat(res, contains("foo")); }
@Test public void testLimitedAddOne() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(5); acc.add("foo"); List<String> res = acc.finish(); assertThat(res, hasSize(1)); assertThat(res, contains("foo")); }
@Test public void testLimitedAddThreeLimit2() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(2); acc.add("foo"); acc.add("bar"); acc.add("zed"); List<String> res = acc.finish(); assertThat(res, hasSize(2)); assertThat(res, contains("zed", "foo")); }
@Test public void testUnlimitedAddThree() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(-1); acc.add("foo"); acc.add("bar"); acc.add("zed"); List<String> res = acc.finish(); assertThat(res, hasSize(3)); assertThat(res, contains("zed", "foo", "bar")); } }
@Test public void testLimitedAddThree() { SortedListAccumulator<String> acc = SortedListAccumulator.decreasing(5); acc.add("foo"); acc.add("bar"); acc.add("zed"); List<String> res = acc.finish(); assertThat(res, hasSize(3)); assertThat(res, contains("zed", "foo", "bar")); }
while (hiter.hasNext()) { Long2ObjectMap.Entry<SortedListAccumulator<Neighbor>> me = hiter.next(); neighbors.put(me.getLongKey(), me.getValue().finish());
/** * Finish accumulating and return the accumulated results. * * When this method is called, the accumulator is reset and can be used to accumulate a fresh set of results. * * @return The accumulated results, in nonincreasing order of score. */ public ResultList finish() { return Results.newResultList(accum.finish()); }
public ResultMap finishMap() { return Results.newResultMap(accum.finish()); } }
while (hiter.hasNext()) { Long2ObjectMap.Entry<SortedListAccumulator<Neighbor>> me = hiter.next(); neighbors.put(me.getLongKey(), me.getValue().finish());