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

8
LINES

< > BotCompany Repo | #1020655 // cloneHashSet - safely clone a collection to HashSet

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

Libraryless. Click here for Pure Java version (1742L/11K).

static <A> HashSet<A> cloneHashSet(Collection<A> set) {
  if (set == null) ret new HashSet;
  synchronized(collectionMutex(set)) {
    HashSet<A> s = new(l(set));
    s.addAll(set);
    ret s;
  }
}

Author comment

Began life as a copy of #1005270

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1020655
Snippet name: cloneHashSet - safely clone a collection to HashSet
Eternal ID of this version: #1020655/3
Text MD5: ad453ddef4ae30862e12df152c0e88d1
Transpilation MD5: 3d89b789d05780ea7cb7744a48a3b30f
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-11 01:32:58
Source code size: 205 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 362 / 474
Version history: 2 change(s)
Referenced in: [show references]