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

19
LINES

< > BotCompany Repo | #1019581 // newSubListOrSame - return cloned subList or original list if full range

JavaX fragment (include)

1  
static <A> L<A> newSubListOrSame(L<A> l, int startIndex) {
2  
  ret newSubListOrSame(l, startIndex, l(l));
3  
}
4  
5  
static <A> L<A> newSubListOrSame(L<A> l, int startIndex, int endIndex) {
6  
  if (l == null) null;
7  
  int n = l(l);
8  
  startIndex = max(0, startIndex);
9  
  endIndex = min(n, endIndex);
10  
  if (startIndex >= endIndex) ret ll();
11  
  if (startIndex == 0 && endIndex == n) ret l;
12  
  ret cloneList(l.subList(startIndex, endIndex));
13  
}
14  
15  
ifclass IntRange
16  
static <A> L<A> newSubListOrSame(L<A> l, IntRange r) {
17  
  ret newSubListOrSame(l, r.start, r.end);
18  
}
19  
endif

Author comment

Began life as a copy of #1002310

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019581
Snippet name: newSubListOrSame - return cloned subList or original list if full range
Eternal ID of this version: #1019581/4
Text MD5: d7010a19f1b804ffa1cc3748eb9e8a7a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-04 10:38:14
Source code size: 565 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 289 / 329
Version history: 3 change(s)
Referenced in: [show references]