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

15
LINES

< > BotCompany Repo | #1010974 // removeAllBut

JavaX fragment (include)

// returns true if any changes
static <A> bool removeAllBut(Set<A> a, Collection<A> b) {
  bool changes;
  b = asSet(b);
  if (a != null) for (Iterator<A> it = a.iterator(); it.hasNext(); )
    if (!contains(b, it.next())) {
      it.remove();
      set changes;
    }
  ret changes;
}

static <A, B> bool removeAllBut(Map<A, B> a, Collection<A> b) {
  ret a != null && removeAllBut(a.keySet(), b);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010974
Snippet name: removeAllBut
Eternal ID of this version: #1010974/6
Text MD5: 2e54763867e723c75ced560fead99892
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-20 16:45:24
Source code size: 414 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 389 / 454
Version history: 5 change(s)
Referenced in: [show references]