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: 808 / 3262
Version history: 6 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1002559 - cloneMap - safely clone a map; null => HashMap. also: map over cloned list
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1013623 - cloneListSynchronizingOn
#1013990 - cloneListSynchronizingOn
#1018335 - cloneListOrNull
#1019909 - cloneLinkedList - now safely clones a synchroList (synchronizing on it)
#1024252 - cloneList_noSync
#3000382 - Answer for ferdie (>> t = 1, f = 0)