Libraryless. Click here for Pure Java version (2991L/17K).
1 | static <A, B> B syncMapGetOrPut(Map<A, B> map, A key, B value) { |
2 | if (map == null || key == null) ret value; |
3 | synchronized(collectionMutex(map)) { |
4 | B existingValue = map.get(key); |
5 | if (existingValue != null) |
6 | ret existingValue; |
7 | else { |
8 | map.put(key, value); |
9 | ret value; |
10 | } |
11 | } |
12 | } |
Began life as a copy of #1031558
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032016 |
Snippet name: | syncMapGetOrPut |
Eternal ID of this version: | #1032016/1 |
Text MD5: | a95e3651b5be7d8cc549ddaf88d8d379 |
Transpilation MD5: | d6d5e5c0533b64cb3e5bd01e21579e8f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-11 02:18:22 |
Source code size: | 318 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 164 / 221 |
Referenced in: | [show references] |