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).

static <A, B> IterableIterator<Pair<A, B>> mapPairs(Map<A, B> map) {
  final Iterator<Map.Entry<A, B>> it = map.entrySet().iterator();
  ret iteratorFromFunction(func -> Pair<A, B> {
    if (it.hasNext()) {
      Map.Entry<A, B> entry = it.next();
      ret pair(entry.getKey(), entry.getValue());
    }
    null;
  });
}

static <A, B, C> L<C> mapPairs(Iterable<Pair<A, B>> l, IF2<A, B, C> f) {
  ret mapPairsToList(l, f);
}

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz, 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: 250 / 249
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1012265 & http://1012265.tinybrain.de