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

20
LINES

< > BotCompany Repo | #1033118 // intListToByteList_littleEndian - wrap as virtual list with get/set

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

Libraryless. Click here for Pure Java version (4041L/23K).

1  
static L<Byte> intListToByteList_littleEndian(L<Int> l) {
2  
  if (l == null) null;
3  
  int n = l(l)*4;
4  
  
5  
  ret new RandomAccessAbstractList<Byte>() {
6  
    public int size() { ret n; }
7  
    
8  
    public Byte get(int i) {
9  
      ret byteFromInt_littleEndian(l.get(i/4), i & 3);
10  
    }
11  
    
12  
    public Byte set(int i, Byte val) {
13  
      int old = l.get(i/4);
14  
      int newInt = replaceByteInInt_littleEndian(old, i & 3, val);
15  
      if (old != newInt)
16  
        l.set(i/4, newInt);
17  
      ret byteFromInt_littleEndian(old, i & 3);
18  
    }
19  
  };
20  
}

Author comment

Began life as a copy of #1033086

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033118
Snippet name: intListToByteList_littleEndian - wrap as virtual list with get/set
Eternal ID of this version: #1033118/12
Text MD5: 45d2c03f939e234bc458c2a570fb9f4f
Transpilation MD5: 5bcc9af4ed9fefc728bd650f4dcaa75b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 17:39:23
Source code size: 546 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 286
Version history: 11 change(s)
Referenced in: [show references]