Selection { public static ImmutableList<ParseValue> getAllValues(final ParseGraph graph, final Predicate<ParseValue> predicate, final int limit) { return getAllValues(ImmutableList.create(graph), new ImmutableList<>(), predicate, limit).computeResult(); } private  Selection(); static boolean hasRootAtOffset(final ParseGraph graph, final Token definition, final BigInteger offset, final Source source); static Trampoline<Optional<ParseItem>> findItemAtOffset(final ImmutableList<ParseItem> items, final BigInteger offset, final Source source); static ImmutableList<ParseValue> getAllValues(final ParseGraph graph, final Predicate<ParseValue> predicate, final int limit); static ImmutableList<ParseValue> getAllValues(final ParseGraph graph, final Predicate<ParseValue> predicate); static ImmutableList<T> reverse(final ImmutableList<T> list); static ImmutableList<ParseItem> getAllRoots(final ParseGraph graph, final Token definition); static final int NO_LIMIT; }
@Test public void limit() { Optional<ParseState> parseState = rep(any("a")).parse(env(stream(1, 2, 3, 4, 5))); Assert.assertTrue(parseState.isPresent()); for (int i = 0; i < 7; i++) { assertEquals(Math.min(5, i), getAllValues(parseState.get().order, (value) -> value.matches("a"), i).size); } }