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).

static <A, B, C extends Map<A, B>> C syncMapRemove_deleteMapIfEmpty(C map, A key) {
  if (map != null && key != null)
    synchronized(collectionMutex(map)) {
      map.remove(key);
      if (map.isEmpty())
        null;
    }
  ret map;
}

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