Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

6
LINES

< > BotCompany Repo | #1010630 // popRandomElement - return random element and remove it from list

JavaX fragment (include)

static <A> A popRandomElement(L<A> l) {
  int i = random(l(l));
  A a = get(l, i);
  if (a != null) l.remove(i);
  ret a;
}

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: 344 / 363
Version history: 1 change(s)
Referenced in: [show references]