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

14
LINES

< > BotCompany Repo | #1012265 // mapPairs - iterate over a map in key-value pairs. also synonym of mapPairsToList

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

Libraryless. Click here for Pure Java version (2598L/17K).

1  
static <A, B> IterableIterator<Pair<A, B>> mapPairs(Map<A, B> map) {
2  
  final Iterator<Map.Entry<A, B>> it = map.entrySet().iterator();
3  
  ret iteratorFromFunction(func -> Pair<A, B> {
4  
    if (it.hasNext()) {
5  
      Map.Entry<A, B> entry = it.next();
6  
      ret pair(entry.getKey(), entry.getValue());
7  
    }
8  
    null;
9  
  });
10  
}
11  
12  
static <A, B, C> L<C> mapPairs(Iterable<Pair<A, B>> l, IF2<A, B, C> f) {
13  
  ret mapPairsToList(l, f);
14  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012265
Snippet name: mapPairs - iterate over a map in key-value pairs. also synonym of mapPairsToList
Eternal ID of this version: #1012265/4
Text MD5: 580bea35acdededfb6d584484ae1f5e7
Transpilation MD5: ad007c2e445c11d90f291fc75e723450
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-11 12:58:26
Source code size: 438 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 478 / 576
Version history: 3 change(s)
Referenced in: [show references]