static L newSubListOrSame(L l, int startIndex) { ret newSubListOrSame(l, startIndex, l(l)); } static L newSubListOrSame(L 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 L newSubListOrSame(L l, IntRange r) { ret newSubListOrSame(l, r.start, r.end); } endif