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

13
LINES

< > BotCompany Repo | #1008064 - filterByValue - filter map by value. also synonym of filterByValuePredicate

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

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

static <A, B> Map<A, B> filterByValue(Map<A, B> map, B value) {
  Map<A, B> m2 = similarEmptyMap(map);
  for (A key : keys(map)) {
    B b = map.get(key);
    if (eq(b, value))
      m2.put(key, b);
  }
  ret m2;
}

static <A, B> Map<A, B> lambdaMapLike filterByValue(IPred<B> pred, Map<A, B> map) {
  ret filterByValuePredicate(pred, map);
}

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1008064
Snippet name: filterByValue - filter map by value. also synonym of filterByValuePredicate
Eternal ID of this version: #1008064/4
Text MD5: 501aa2922b286d65d80bf8ab14f78606
Transpilation MD5: 7cc641f107e2d7e2307b895ff986d6b0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-30 13:49:28
Source code size: 354 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 343 / 357
Version history: 3 change(s)
Referenced in: [show references]

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