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)

static <A, B> B getOrCreate_f0(Map<A, B> map, A key, F0<B> create) {
  B b = map.get(key);
  if (b == null)
    mapPut(map, key, b = callF(create));
  ret b;
}

static <A, B> B getOrCreate_f0(Map<A, B> map, A key, IF0<B> create) {
  B b = map.get(key);
  if (b == null)
    mapPut(map, key, b = callF(create));
  ret b;
}

Author comment

Began life as a copy of #1021431

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

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: 14 / 25
Referenced in: [show references]

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