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

13
LINES

< > BotCompany Repo | #1007943 // similarEmptySet - make an effort to create an empty set of same type

JavaX fragment (include)

static Set similarEmptySet(Iterable m) {
  if (m instanceof TreeSet) ret new TreeSet(((TreeSet) m).comparator());
  if (m instanceof LinkedHashSet) ret new LinkedHashSet;
  
  ret new HashSet;
}

static Set similarEmptySet(Map m) {
  if (m instanceof TreeMap) ret new TreeSet(((TreeMap) m).comparator());
  if (m instanceof LinkedHashMap) ret new LinkedHashSet;
  
  ret new HashSet;
}

Author comment

Began life as a copy of #1004367

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007943
Snippet name: similarEmptySet - make an effort to create an empty set of same type
Eternal ID of this version: #1007943/7
Text MD5: a8c20c81d7088400a80caff3c90c76ae
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-09 17:50:41
Source code size: 397 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 509 / 558
Version history: 6 change(s)
Referenced in: [show references]