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

26
LINES

< > BotCompany Repo | #1029531 // IByteMemory64

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

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

sinterface IByteMemory64 {
  byte getByte(long idx);
  int getInt(long idx);
  //void setByte(long idx, byte val);
  long size();
  
  default int[] readIntArray(long start, int len) {
    int[] a = new[len];
    for i to len:
      a[i] = getInt(start+(((long) i) << 2));
    ret a;
  }
  
  default int[] readIntArray(LongRange r) {
    ret r == null ? null : readIntArray(r.start, toInt(r.length()));
  }
  
  default long getLong(long idx) {
    ret twoIntsToLong(getInt(idx), getInt(idx+4));
  }
  
  /*default void setLong(long idx, long val) {
    setInt(idx, firstIntFromLong(val));
    setInt(idx+4, secondIntFromLong(val));
  }*/
}

Author comment

Began life as a copy of #1029375

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029531
Snippet name: IByteMemory64
Eternal ID of this version: #1029531/3
Text MD5: c8a5bd9d318faf76e40c1fffa1bc1d3c
Transpilation MD5: 2823f8012661a2e0a736d9a140a66f58
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-17 23:20:04
Source code size: 666 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 221 / 498
Version history: 2 change(s)
Referenced in: [show references]