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

32
LINES

< > BotCompany Repo | #1029251 // ManagedIntObjects_v1_virtual - works on IIntMemory instead of int[]

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

Uses 11335K of libraries. Click here for Pure Java version (5408L/33K).

1  
// Yeah this subclass relationship is nasty
2  
sclass ManagedIntObjects_v1_virtual extends ManagedIntObjects_v1 {
3  
  replace Addr with int.
4  
  replace BoxedAddr with Int.
5  
  
6  
  IIntMemory vmem;
7  
  
8  
  *(IIntMemory *vmem) { mem = null; }
9  
  
10  
  public long size() { ret (int) vmem.size(); }
11  
  public int get(Addr i) { ret vmem.get(i); }
12  
  public void set(Addr i, int val) { vmem.set(i, val); }
13  
  
14  
  int[] readIntArray(BoxedAddr ptr) {
15  
    if (ptr == 0) null;
16  
    int n = get(ptr++);
17  
    int[] a = new[n];
18  
    for i to n:
19  
      a[i] = get(ptr+i);
20  
    ret a;
21  
  }
22  
  
23  
  void fillMem(int start, int end, int value) {
24  
    for (int i = start; i < end; i++)
25  
      set(i, value);
26  
  }
27  
  
28  
  void memCopy(int src, int dest, int n) {
29  
    for i to n:
30  
      set(dest+i, get(src+i));
31  
  }
32  
}

Author comment

Began life as a copy of #1029226

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: #1029251
Snippet name: ManagedIntObjects_v1_virtual - works on IIntMemory instead of int[]
Eternal ID of this version: #1029251/10
Text MD5: f7461e7953c95c0ac18b4ac50a50360c
Transpilation MD5: 516faf139c1a35628482014a5ce2fd07
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-25 07:51:55
Source code size: 793 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 209 / 493
Version history: 9 change(s)
Referenced in: [show references]