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)

sclass MultiShortArrayInputStream extends InputStream {
  Iterator<short[]> it;
  short[] buf;
  int iBuf;
  
  *(Iterable<short[]> l) { it = iterator(l); }
  
  public int read() {
    while (iBuf >= l(buf)*2)
      if (!it.hasNext()) ret -1;
      else { buf = it.next(); iBuf = 0; }
    short s = buf[iBuf/2];
    int i = (odd(iBuf) ? s >> 8 : s) & 0xFF;
    iBuf++;
    ret i;
  }
}

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: 371 / 913
Version history: 2 change(s)
Referenced in: #1018635 - ZerosInputStream
#1019269 - MultiShortArrayInputStream_resettable - reads from L<short[]>
#1029246 - IntArrayInputStream_littleEndian
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)