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

13
LINES

< > BotCompany Repo | #1018749 // syncRemove - remove & synchronize on collection/map

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

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

static <A> bool syncRemove(Collection<A> c, A b) {
  if (c == null) false;
  synchronized(collectionMutex(c)) { ret c.remove(b); }
}

static <A> A syncRemove(L<A> l, int idx) {
  if (l == null) null;
  synchronized(collectionMutex(l)) { ret l.remove(idx); }
}

static <A, B> B syncRemove(Map<A, B> map, A key) {
  ret map == null ? null : map.remove(key);
}

Author comment

Began life as a copy of #1016979

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1018749
Snippet name: syncRemove - remove & synchronize on collection/map
Eternal ID of this version: #1018749/8
Text MD5: 5214d0237a68b80a36457866a7eee137
Transpilation MD5: b2ea5b39249bf3bc1dfc8ebf2b670e7e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-27 17:04:19
Source code size: 369 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 297 / 380
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1024633 - syncRemoveAll - removeAll & synchronize on collection