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

7
LINES

< > BotCompany Repo | #1002948 // cloneTreeMap - safely clone a map as TreeMap. generously makes a new one if passed map is null

JavaX fragment (include)

1  
static <A, B> Map<A, B> cloneTreeMap(Map<A, B> map) {
2  
  // assume mutex is equal to collection, which will be true unless you explicitly pass a mutex to synchronizedList() which no one ever does.
3  
  if (map == null) ret new TreeMap;
4  
  else synchronized(map) {
5  
    ret new TreeMap(map);
6  
  }
7  
}

Author comment

Began life as a copy of #1002559

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002948
Snippet name: cloneTreeMap - safely clone a map as TreeMap. generously makes a new one if passed map is null
Eternal ID of this version: #1002948/1
Text MD5: 899dde1e3ad68e732f36da7d449f9689
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-30 17:04:29
Source code size: 296 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 652 / 623
Referenced in: [show references]