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)

// TODO: does not detect set type (hash/tree) when it's synchronized
static <A> Set<A> cloneSet(Set<A> set) {
  if (set == null) ret new HashSet;
  synchronized(collectionMutex(set)) {
    Set<A> s = similarEmptySet(set);
    s.addAll(set);
    ret s;
  }
}

Author comment

Began life as a copy of #1002559

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

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/5
Text MD5: be2717c76271d8ce5daa0a8e8fbf433f
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-05 14:00:40
Source code size: 265 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 341 / 354
Version history: 4 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1005270 & http://1005270.tinybrain.de