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

30
LINES

< > BotCompany Repo | #1019269 // MultiShortArrayInputStream_resettable - reads from L<short[]>

JavaX fragment (include)

sclass MultiShortArrayInputStream_resettable extends InputStream {
  L<short[]> l;
  int idx, iBuf;
  int mark_idx, mark_iBuf;
  bool bigEndian;
  
  *(L<short[]> *l) {}
  
  public bool markSupported() { true; }
  
  public void mark(int n) {
    mark_idx = idx;
    mark_iBuf = iBuf;
  }
  
  public void reset() {
    idx = mark_idx;
    iBuf = mark_iBuf;
  }
  
  public int read() {
    while (iBuf >= l(get(l, idx))*2)
      if (idx >= l(l)-1) ret -1;
      else { ++idx; iBuf = 0; }
    short s = get(l, idx)[iBuf/2];
    int i = (odd(iBuf) != bigEndian ? s >> 8 : s) & 0xFF;
    iBuf++;
    ret i;
  }
}

Author comment

Began life as a copy of #1018606

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019269
Snippet name: MultiShortArrayInputStream_resettable - reads from L<short[]>
Eternal ID of this version: #1019269/4
Text MD5: 701f5deddf3533ca06644c9bc0aa36ae
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-28 18:20:56
Source code size: 640 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 263 / 806
Version history: 3 change(s)
Referenced in: [show references]