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

10
LINES

< > BotCompany Repo | #1019909 // cloneLinkedList - now safely clones a synchroList (synchronizing on it)

JavaX fragment (include)

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

Author comment

Began life as a copy of #1001634

download  show line numbers  debug dex  old transpilations   

Travelled to 10 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019909
Snippet name: cloneLinkedList - now safely clones a synchroList (synchronizing on it)
Eternal ID of this version: #1019909/1
Text MD5: b6bc7f82e7f1c013efbf0564caab4d63
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-30 21:43:48
Source code size: 322 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 266 / 308
Referenced in: [show references]