static <A> L<A> selectRandom_fast(L<A> l, int k) { int n = l(l); l = cloneList(l); for (int i = n - 1; i >= n-k; i--) { int j = random(i+1); swapElements(l, i, j); } ret subList(l, n-k); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011028 |
Snippet name: | selectRandom_fast |
Eternal ID of this version: | #1011028/4 |
Text MD5: | e96db2d1cda900a7421088ca2b7fe0bd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-11 19:38:35 |
Source code size: | 214 bytes / 9 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 440 / 497 |
Version history: | 3 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |