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)

static <A> L<A> newSubListOrSame(L<A> l, int startIndex) {
  ret newSubListOrSame(l, startIndex, l(l));
}

static <A> L<A> newSubListOrSame(L<A> l, int startIndex, int endIndex) {
  if (l == null) null;
  int n = l(l);
  startIndex = max(0, startIndex);
  endIndex = min(n, endIndex);
  if (startIndex >= endIndex) ret ll();
  if (startIndex == 0 && endIndex == n) ret l;
  ret cloneList(l.subList(startIndex, endIndex));
}

ifclass IntRange
static <A> L<A> newSubListOrSame(L<A> l, IntRange r) {
  ret newSubListOrSame(l, r.start, r.end);
}
endif

Author comment

Began life as a copy of #1002310

download  show line numbers  debug dex   

Travelled to 10 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tvejysmllsmz, 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: 99 / 132
Version history: 3 change(s)
Referenced in: [show references]

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