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

26
LINES

< > BotCompany Repo | #1031898 // ShortArrayInputStream - reads from short[]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3047L/17K).

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

Author comment

Began life as a copy of #1019269

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1031898
Snippet name: ShortArrayInputStream - reads from short[]
Eternal ID of this version: #1031898/6
Text MD5: 00f54e6918b4f1ebdb15b94d82b65748
Transpilation MD5: 1a7ac4dbad665b20fb40a428fe5775e3
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-24 06:47:29
Source code size: 487 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 94 / 226
Version history: 5 change(s)
Referenced in: [show references]