1 | static <A> A popRandomElement(L<A> l) { |
2 | int i = random(l(l)); |
3 | A a = get(l, i); |
4 | if (a != null) l.remove(i); |
5 | ret a; |
6 | } |
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: | #1010630 |
Snippet name: | popRandomElement - return random element and remove it from list |
Eternal ID of this version: | #1010630/2 |
Text MD5: | dff3b9954455543905dd100fec3e78dc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-09-23 23:33:32 |
Source code size: | 128 bytes / 6 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 413 / 438 |
Version history: | 1 change(s) |
Referenced in: | [show references] |