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

9
LINES

< > BotCompany Repo | #1032633 // addAndRemoveSomeRandomStrings

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (3981L) is out of date.

static <A extends Set<S>> A addAndRemoveSomeRandomStrings(A set, int nAdd, int nRemove) {
  repeat nAdd {
    set.add(aGlobalID());
  }
  var it = shuffledIterator(cloneList(set));
  while (nRemove-- > 0 && it.hasNext())
    set.remove(it.next());
  ret set;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032633
Snippet name: addAndRemoveSomeRandomStrings
Eternal ID of this version: #1032633/3
Text MD5: b4b081563f644813abba767f282cbbd4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-29 22:45:30
Source code size: 268 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 161 / 223
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)