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


< > BotCompany Repo | #1002310 // subList function - use instead of List.subList

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2971L/17K).

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

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

static <A> L<A> subList(int startIndex, int endIndex, L<A> l) {
  ret subList(l, startIndex, endIndex);

static <A> L<A> subList(L<A> l, int startIndex, int endIndex) {
  if (l == null) null;
  int n = l(l);
  startIndex = Math.max(0, startIndex);
  endIndex = Math.min(n, endIndex);
  if (startIndex > endIndex) ret ll();
  if (startIndex == 0 && endIndex == n) ret l;
  ifdef OurSubLists
    ret ourSubList_noRangeCheck(l, startIndex, endIndex);
  ifndef OurSubLists
    ret l.subList(startIndex, endIndex);

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

Author comment

Began life as a copy of #1001911

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002310
Snippet name: subList function - use instead of List.subList
Eternal ID of this version: #1002310/9
Text MD5: 561528862a976b860c0a1ac7f8d48688
Transpilation MD5: dd1ab59fd583a71fbca9b917a63ae519
Author: stefan
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-24 02:46:12
Source code size: 845 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 754 / 4063
Version history: 8 change(s)
Referenced in: [show references]