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

11
LINES

< > BotCompany Repo | #1028090 // countKeysWithValue

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

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

static <A, B> int countKeysWithValue(Map<A, B> map, B value) {
  int n = 0;
  for (A key : keys(map))
    if (eq(map.get(key), value))
      ++n;
  ret n;
}

static <A, B> int countKeysWithValue(B value, Map<A, B> map) {
  ret countKeysWithValue(map, value);
}

Author comment

Began life as a copy of #1008062

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: #1028090
Snippet name: countKeysWithValue
Eternal ID of this version: #1028090/2
Text MD5: c1ea1fddcee16346607269036d9f8245
Transpilation MD5: b845bef5b5b0ebd2335f8e819a6a591f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-18 14:08:38
Source code size: 266 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 231 / 317
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)