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

17
LINES

< > BotCompany Repo | #1028565 // mapMinusKeys - map minus some keys

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

Libraryless. Click here for Pure Java version (2806L/16K).

static <A, B> Map<A, B> mapMinusKeys(Map<A, B> map, A... keys) {
  ret mapMinusKeys(map, asList(keys));
}

static <A, B> Map<A, B> mapMinusKeys(Map<A, B> map, Cl<A> keys) {
  if (empty(keys) || empty(map)) ret map;
  keys = asSet(keys);
  Map<A, B> m2 = similarEmptyMap(map);
  for (A key, B val : map)
    if (!keys.contains(key))
      m2.put(key, val);
  ret m2;
}

static <A, B> Map<A, B> mapMinusKeys(Cl<A> keys, Map<A, B> map) {
  ret mapMinusKeys(map, keys);
}

Author comment

Began life as a copy of #1004210

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: #1028565
Snippet name: mapMinusKeys - map minus some keys
Eternal ID of this version: #1028565/4
Text MD5: a478a28ce943106b3298aaf5c003bafe
Transpilation MD5: 6cef768a12af7ddbb33fdc6b09ba51f3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-11 16:33:07
Source code size: 483 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 241 / 352
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)