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

9
LINES

< > BotCompany Repo | #1005270 // cloneSet - safely clone a set, try to match original type

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2768L/16K).

1  
// TODO: does not detect set type (hash/tree) when it's synchronized
2  
static <A> Set<A> cloneSet(Cl<A> set) {
3  
  if (set == null) ret new HashSet;
4  
  synchronized(collectionMutex(set)) {
5  
    Set<A> s = similarEmptySet(set);
6  
    s.addAll(set);
7  
    ret s;
8  
  }
9  
}

Author comment

Began life as a copy of #1002559

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005270
Snippet name: cloneSet - safely clone a set, try to match original type
Eternal ID of this version: #1005270/6
Text MD5: fd10209283de6c3d7082bfe8cf6d73d4
Transpilation MD5: 2c4ac828c3fa4e111ceaed69811112a2
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-07 17:10:18
Source code size: 264 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 655 / 754
Version history: 5 change(s)
Referenced in: [show references]