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

13
LINES

< > BotCompany Repo | #1024526 // getOrCreate_f0 - map lookup or create from function on key

JavaX fragment (include)

1  
static <A, B> B getOrCreate_f0(Map<A, B> map, A key, F0<B> create) {
2  
  B b = map.get(key);
3  
  if (b == null)
4  
    mapPut(map, key, b = callF(create));
5  
  ret b;
6  
}
7  
8  
static <A, B> B getOrCreate_f0(Map<A, B> map, A key, IF0<B> create) {
9  
  B b = map.get(key);
10  
  if (b == null)
11  
    mapPut(map, key, b = callF(create));
12  
  ret b;
13  
}

Author comment

Began life as a copy of #1021431

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1024526
Snippet name: getOrCreate_f0 - map lookup or create from function on key
Eternal ID of this version: #1024526/1
Text MD5: bbe0937e46609817bc5e0a9e4d96a3d9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-17 16:06:24
Source code size: 333 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 219 / 263
Referenced in: [show references]