Libraryless. Click here for Pure Java version (4279L/24K).
// always keeps a dynamically updated list of the n most probable // results // not synchronized sclass SetOfMostProbable<A> extends TreeSetWithDuplicates<WithProbability<A>> { int maxSize = 10; *() {} *(int *maxSize) {} public bool add(WithProbability<A> a) { if (a == null) false; super.add(a); truncate(); true; } void setMaxSize(int maxSize) { this.maxSize = maxSize; truncate(); } void truncate { truncateTreeSetWithDuplicates(this, maxSize); } }
Began life as a copy of #1032061
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032063 |
Snippet name: | SetOfMostProbable |
Eternal ID of this version: | #1032063/7 |
Text MD5: | b5e0fa14e0e8c53460b73529c1b6665a |
Transpilation MD5: | eff28acc8e5b802198d2594530eb9a7d |
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:15:58 |
Source code size: | 533 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 168 / 313 |
Version history: | 6 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |