Libraryless. Click here for Pure Java version (5300L/30K).
// always keeps a dynamically updated list of the n most probable // results // for maxResults default, see SetOfMostProbable // not synchronized srecord noeq PSCollectMostProbable<A>( IVF1<IVF1<WithProbability<A>>> action) implements IF0<Set<WithProbability<A>>>, Steppable { new ProbabilisticScheduler ps; new SetOfMostProbable<A> results; bool verbose; *() {} *(int maxResults) { setMaxResults(maxResults); } *(int maxResults, ProbabilisticScheduler *ps, IVF1<IVF1<WithProbability<A>>> *action) { setMaxResults(maxResults); } *(int maxResults, IVF2<IProbabilisticScheduler, IVF1<WithProbability<A>>> action) { setMaxResults(maxResults); this.action = out -> action.get(ps, out); } void add(WithProbability<A> result) { results.add(result); } selfType run() { action?.get(result -> add(result)); this; } void setMaxResults(int maxResults) { results.setMaxSize(maxResults); } selfType verbose(bool verbose) { this.verbose = verbose; this; } // results sorted by probability. instant public Set<WithProbability<A>> results aka get() { ret results; } public bool step() { ret ps.step(); } }
Began life as a copy of #1032029
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
| Snippet ID: | #1032061 | 
| Snippet name: | PSCollectMostProbable | 
| Eternal ID of this version: | #1032061/23 | 
| Text MD5: | 2bc95f75130f9fdf6d49338e52bc29f2 | 
| Transpilation MD5: | b59f2b95a74107ed518c8f60491987d7 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2021-08-11 10:19:30 | 
| Source code size: | 1271 bytes / 52 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 413 / 652 | 
| Version history: | 22 change(s) | 
| Referenced in: | [show references] |