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)

static <A> ArrayList<A> cloneList(Iterable<A> l) {
  ret l instanceof Collection ? cloneList((Collection) l) : asList(l);
}

static <A> ArrayList<A> cloneList(Collection<A> l) {
  if (l == null) ret new L;
  synchronized(collectionMutex(l)) {
    ret new ArrayList<A>(l);
  }
}

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: 794 / 3247
Version history: 6 change(s)
Referenced in: [show references]