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)

static <A> LinkedList<A> cloneLinkedList(Iterable<A> l) {
  ret l instanceof Collection ? cloneLinkedList((Collection) l) : asLinkedList(l);
}

static <A> LinkedList<A> cloneLinkedList(Collection<A> l) {
  if (l == null) ret new LinkedList;
  synchronized(collectionMutex(l)) {
    ret new LinkedList<A>(l);
  }
}

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