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

13
LINES

< > BotCompany Repo | #1012674 // syncGet

JavaX fragment (include)

1  
static <A> A syncGet(L<A> l, int idx) {
2  
  if (l == null || idx < 0) null;
3  
  synchronized(l) {
4  
    ret idx < l(l) ? l.get(idx) : null;
5  
  }
6  
}
7  
8  
static <A, B> B syncGet(Map<A, B> map, A a) {
9  
  if (map == null) null;
10  
  synchronized(map) {
11  
    ret map.get(a);
12  
  }
13  
}

Author comment

Began life as a copy of #1003807

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012674
Snippet name: syncGet
Eternal ID of this version: #1012674/2
Text MD5: 02877e657120a43224225837a6bd8bdf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-24 22:55:20
Source code size: 271 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 467 / 520
Version history: 1 change(s)
Referenced in: [show references]