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

17
LINES

< > BotCompany Repo | #1018606 // MultiShortArrayInputStream - reads from L<short[]>

JavaX fragment (include)

1  
sclass MultiShortArrayInputStream extends InputStream {
2  
  Iterator<short[]> it;
3  
  short[] buf;
4  
  int iBuf;
5  
  
6  
  *(Iterable<short[]> l) { it = iterator(l); }
7  
  
8  
  public int read() {
9  
    while (iBuf >= l(buf)*2)
10  
      if (!it.hasNext()) ret -1;
11  
      else { buf = it.next(); iBuf = 0; }
12  
    short s = buf[iBuf/2];
13  
    int i = (odd(iBuf) ? s >> 8 : s) & 0xFF;
14  
    iBuf++;
15  
    ret i;
16  
  }
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018606
Snippet name: MultiShortArrayInputStream - reads from L<short[]>
Eternal ID of this version: #1018606/3
Text MD5: c6f81b59ea0b4f2037e5808c2f2842e5
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-07 16:22:03
Source code size: 402 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 291 / 834
Version history: 2 change(s)
Referenced in: [show references]