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

24
LINES

< > BotCompany Repo | #1029248 // IIntMemory

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

Libraryless. Click here for Pure Java version (2620L/16K).

1  
sinterface IIntMemory {
2  
  int get(int idx); // idx = unsigned int
3  
  default int read(int idx) { ret get(idx); }
4  
  void set(int idx, int val);
5  
  long size(); // in ints
6  
  
7  
  default int[] readArray(int 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 long getLong(int idx) {
15  
    ret twoIntsToLong(get(idx), get(idx+1));
16  
  }
17  
  
18  
  default void setLong(int idx, long val) {
19  
    set(idx, firstIntFromLong(val));
20  
    set(idx+1, secondIntFromLong(val));
21  
  }
22  
  
23  
  default void ensureSize(int size) { unimplemented(); }
24  
}

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: #1029248
Snippet name: IIntMemory
Eternal ID of this version: #1029248/10
Text MD5: bd200fa7dbe279e42de3bbc2ff2120f5
Transpilation MD5: e48002aeec2852600c495c1f1c8e3780
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-07 14:10:08
Source code size: 601 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 225 / 528
Version history: 9 change(s)
Referenced in: [show references]