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

15
LINES

< > BotCompany Repo | #1029235 // convertListElementsBothWays - virtual list with two converters for both getting and setting

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

Libraryless. Click here for Pure Java version (2562L/16K).

static <A, B> L<B> lambdaMapLike convertListElementsBothWays(IF1<A, B> fGet, IF1<B, A> fSet, L<A> l) {
  ret new RandomAccessAbstractList<B> {
    final int size = l(l);

    public int size() { ret size; }
    public B get(int i) {
      ret fGet.get(l.get(i));
    }
    public B set(int i, B b) {
      B old = get(i);
      l.set(i, fSet.get(b));
      ret old;
    }
  };
}

Author comment

Began life as a copy of #1018394

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: #1029235
Snippet name: convertListElementsBothWays - virtual list with two converters for both getting and setting
Eternal ID of this version: #1029235/4
Text MD5: 67f180aa3b3983ce94be8b652c9365b3
Transpilation MD5: ac122921cc0e44b12d5731e448b79398
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-26 20:00:05
Source code size: 392 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 147 / 225
Version history: 3 change(s)
Referenced in: [show references]