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

11
LINES

< > BotCompany Repo | #1028243 // lineComp_listWithGap

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

Libraryless. Click here for Pure Java version (39L/1K).

// virtual view into a list that with a "gap" (elements in the middle being removed)
static <A> L<A> lineComp_listWithGap(L<A> l, int copyTo, int copyFrom) {
  if (copyFrom == copyTo) ret l;
  ret new RandomAccessAbstractList<A> {
    int size = l.size()-(copyFrom-copyTo);
    public int size() { ret size; }
    public A get(int i) {
      ret l.get(i < copyTo ? i : i+(copyFrom-copyTo));
    }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028243
Snippet name: lineComp_listWithGap
Eternal ID of this version: #1028243/5
Text MD5: d253a4779ef6f7f5c1fdad73ce01e7a4
Transpilation MD5: 0bf3edf4e1f1dd8f15bf1159b2fb0a2b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-27 22:21:46
Source code size: 413 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 184 / 300
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)