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

8
LINES

< > BotCompany Repo | #1027916 // takeFirstFromMap

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

Libraryless. Click here for Pure Java version (42L/1K).

static <A, B> Map<A, B> takeFirstFromMap(int n, Map<A, B> map) {
  if (map == null) null;
  Map<A, B> map2 = similarEmptyMap(map);
  if (n > 0)
    for (Map.Entry<A, B> e : map.entrySet())
      if (n-- <= 0) break; else map2.put(e.getKey(), e.getValue());
  ret map2;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027916
Snippet name: takeFirstFromMap
Eternal ID of this version: #1027916/3
Text MD5: c5f73c6e78c1e4783b24d79b0dde829d
Transpilation MD5: 2e320408d7c72f79d8272ddf4cf78263
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-17 11:37:45
Source code size: 277 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 233 / 324
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)