// always keeps a dynamically updated list of the n most probable // results // not synchronized srecord noeq PSCollectMostProbable( int maxResults, IVF1>> action) implements IF0>> { new ProbabilisticScheduler ps; new SetOfMostProbable results; bool verbose; *(int *maxResults, ProbabilisticScheduler *ps, IVF1>> *action) {} *(int *maxResults, IVF2>> action) { this.action = out -> action.get(ps, out); } void add(WithProbability result) { results.add(result); } selfType run() { results.maxSize = maxResults; action.get(result -> add(result)); this; } selfType verbose(bool verbose) { this.verbose = verbose; this; } // results sorted by probability. instant public Set> results aka get() { ret results; } }