1 | static <A> L<A> selectRandom_fast(L<A> l, int k) { |
2 | int n = l(l); |
3 | l = cloneList(l); |
4 | for (int i = n - 1; i >= n-k; i--) { |
5 | int j = random(i+1); |
6 | swapElements(l, i, j); |
7 | } |
8 | ret subList(l, n-k); |
9 | } |
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: | 313 / 361 |
Version history: | 3 change(s) |
Referenced in: | [show references] |