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)

1  
sclass MultiShortArrayInputStream_resettable extends InputStream {
2  
  L<short[]> l;
3  
  int idx, iBuf;
4  
  int mark_idx, mark_iBuf;
5  
  bool bigEndian;
6  
  
7  
  *(L<short[]> *l) {}
8  
  
9  
  public bool markSupported() { true; }
10  
  
11  
  public void mark(int n) {
12  
    mark_idx = idx;
13  
    mark_iBuf = iBuf;
14  
  }
15  
  
16  
  public void reset() {
17  
    idx = mark_idx;
18  
    iBuf = mark_iBuf;
19  
  }
20  
  
21  
  public int read() {
22  
    while (iBuf >= l(get(l, idx))*2)
23  
      if (idx >= l(l)-1) ret -1;
24  
      else { ++idx; iBuf = 0; }
25  
    short s = get(l, idx)[iBuf/2];
26  
    int i = (odd(iBuf) != bigEndian ? s >> 8 : s) & 0xFF;
27  
    iBuf++;
28  
    ret i;
29  
  }
30  
}

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: 269 / 812
Version history: 3 change(s)
Referenced in: [show references]