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

10
LINES

< > BotCompany Repo | #1001634 - cloneList - now safely clones a synchroList (synchronizing on it)

JavaX fragment (include)

1  
static <A> ArrayList<A> cloneList(Iterable<A> l) {
2  
  ret l instanceof Collection ? cloneList((Collection) l) : asList(l);
3  
}
4  
5  
static <A> ArrayList<A> cloneList(Collection<A> l) {
6  
  if (l == null) ret new L;
7  
  synchronized(collectionMutex(l)) {
8  
    ret new ArrayList<A>(l);
9  
  }
10  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001634
Snippet name: cloneList - now safely clones a synchroList (synchronizing on it)
Eternal ID of this version: #1001634/7
Text MD5: 790820ee2871c90477273ce4214f383e
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-20 17:04:57
Source code size: 286 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 597 / 3011
Version history: 6 change(s)
Referenced in: [show references]