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

9
LINES

< > BotCompany Repo | #1031194 // syncMapRemove_deleteMapIfEmpty

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

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

1  
static <A, B, C extends Map<A, B>> C syncMapRemove_deleteMapIfEmpty(C map, A key) {
2  
  if (map != null && key != null)
3  
    synchronized(collectionMutex(map)) {
4  
      map.remove(key);
5  
      if (map.isEmpty())
6  
        null;
7  
    }
8  
  ret map;
9  
}

Author comment

Began life as a copy of #1030802

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031194
Snippet name: syncMapRemove_deleteMapIfEmpty
Eternal ID of this version: #1031194/1
Text MD5: 2271d840e83b67c7cca1482998212407
Transpilation MD5: 75cb3ec74c4abf8f0671d35e530e4bb1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-19 23:51:37
Source code size: 247 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 206 / 466
Referenced in: [show references]