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

26
LINES

< > BotCompany Repo | #1029375 // IIntMemory64

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

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

1  
sinterface IIntMemory64 {
2  
  int get(long idx);
3  
  default int read(long idx) { ret get(idx); }
4  
  void set(long idx, int val);
5  
  long size();
6  
  
7  
  default int[] readArray(long start, int len) {
8  
    int[] a = new[len];
9  
    for i to len:
10  
      a[i] = get(start+i);
11  
    ret a;
12  
  }
13  
  
14  
  default int[] readArray(LongRange r) {
15  
    ret r == null ? null : readArray(r.start, toInt(r.length()));
16  
  }
17  
  
18  
  default long getLong(long idx) {
19  
    ret twoIntsToLong(get(idx), get(idx+1));
20  
  }
21  
  
22  
  default void setLong(long idx, long val) {
23  
    set(idx, firstIntFromLong(val));
24  
    set(idx+1, secondIntFromLong(val));
25  
  }
26  
}

Author comment

Began life as a copy of #1029248

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: #1029375
Snippet name: IIntMemory64
Eternal ID of this version: #1029375/4
Text MD5: 1bcf91fc121a96f96cbc6a322ff5eff4
Transpilation MD5: 8f8e545c47364e96b67dfe97d5f4908c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-09 13:08:29
Source code size: 632 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 200 / 473
Version history: 3 change(s)
Referenced in: [show references]