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

22
LINES

< > BotCompany Repo | #1001914 - emptyList - returning a new list now cause want mutable lists

JavaX fragment (include)

1  
static ArrayList emptyList() {
2  
  ret new ArrayList;
3  
  //ret Collections.emptyList();
4  
}
5  
6  
static ArrayList emptyList(int capacity) {
7  
  ret new ArrayList(max(0, capacity));
8  
}
9  
10  
// Try to match capacity
11  
static ArrayList emptyList(Iterable l) {
12  
  ret l instanceof Collection ? emptyList(((Collection) l).size()) : emptyList();
13  
}
14  
15  
static ArrayList emptyList(O[] l) {
16  
  ret emptyList(l(l));
17  
}
18  
19  
// get correct type at once
20  
static <A> ArrayList<A> emptyList(Class<A> c) {
21  
  ret new ArrayList;
22  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 20 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, wtqryiryparv, xrpafgyirdlv

No comments. add comment

Snippet ID: #1001914
Snippet name: emptyList - returning a new list now cause want mutable lists
Eternal ID of this version: #1001914/10
Text MD5: 6ea5405862b02bd3833cd18e00a16849
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-23 15:03:20
Source code size: 505 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 586 / 7373
Version history: 9 change(s)
Referenced in: [show references]