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

13
LINES

< > BotCompany Repo | #1010788 // lookupAllOpt2 - look up a whole list in a map, returning only found entries; also returns keys not found

JavaX fragment (include)

1  
static <A, B> Pair<L<B>, L<A>> lookupAllOpt2(Map<A, B> map, Collection<A> l) {
2  
  new L<B> out;
3  
  new L<A> notfound;
4  
  if (l != null) for (A a : l) {
5  
    B b = map.get(a);
6  
    if (b != null) out.add(b); else notfound.add(a);
7  
  }
8  
  ret pair(out, notfound);
9  
}
10  
11  
static <A, B> Pair<L<B>, L<A>> lookupAllOpt2(Collection<A> l, Map<A, B> map) {
12  
  ret lookupAllOpt2(map, l);
13  
}

Author comment

Began life as a copy of #1010182

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: #1010788
Snippet name: lookupAllOpt2 - look up a whole list in a map, returning only found entries; also returns keys not found
Eternal ID of this version: #1010788/1
Text MD5: ff92b705454a34c4d718d2041360d82c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-03 17:33:35
Source code size: 379 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 467 / 485
Referenced in: [show references]