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).

static L<Byte> intListToByteList_littleEndian(L<Int> l) {
  if (l == null) null;
  int n = l(l)*4;
  
  ret new RandomAccessAbstractList<Byte>() {
    public int size() { ret n; }
    
    public Byte get(int i) {
      ret byteFromInt_littleEndian(l.get(i/4), i & 3);
    }
    
    public Byte set(int i, Byte val) {
      int old = l.get(i/4);
      int newInt = replaceByteInInt_littleEndian(old, i & 3, val);
      if (old != newInt)
        l.set(i/4, newInt);
      ret byteFromInt_littleEndian(old, i & 3);
    }
  };
}

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: 192 / 285
Version history: 11 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1033226 - intListToByteArray_littleEndian