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

8
LINES

< > BotCompany Repo | #1001927 // diff - get elements of one collection that are not in another collection (works on any collection type)

JavaX fragment (include)

static L<S> diff(Collection<S> a, Collection<S> b) {
  Set<S> set = asSet(b);
  L<S> l = new ArrayList();
  for (S s : a)
    if (!set.contains(s))
      l.add(s);
  ret l;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001927
Snippet name: diff - get elements of one collection that are not in another collection (works on any collection type)
Eternal ID of this version: #1001927/1
Text MD5: 89dec199cb1e03bc887df5460f38ce05
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-29 15:28:18
Source code size: 181 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 789 / 2531
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1002986 - minus - get list without certain elements; subtract BigIntegers
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1009122 - containsAll
#3000382 - Answer for ferdie (>> t = 1, f = 0)