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

28
LINES

< > BotCompany Repo | #1026148 // SparseIntArray2D_65536 - max 65536 rows, 65536 cols

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

Libraryless. Click here for Pure Java version (2412L/15K).

1  
final sclass SparseIntArray2D_65536 implements IIntArray2D {
2  
  int nrows, ncols;
3  
  IntIntMap entries = new(256, 0.75f);
4  
  
5  
  *() {}
6  
  *(int *nrows, int *ncols) {}
7  
  
8  
  public int nrows() { ret nrows; }
9  
  public int ncols() { ret ncols; }
10  
11  
  /** Returns A(i, j). */
12  
  public int get(int i, int j) {
13  
    ret entries.get(combine(i, j));
14  
  }
15  
16  
  /** Sets A(i, j). */
17  
  public int set(int i, int j, int x) {
18  
    if (x == 0)
19  
      entries.remove(combine(i, j));
20  
    else
21  
      entries.put(combine(i, j), x);
22  
    ret x;
23  
  }
24  
  
25  
  static int combine(int i, int j) {
26  
    ret i << 16 | j;
27  
  }
28  
}

Author comment

Began life as a copy of #1026140

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1026148
Snippet name: SparseIntArray2D_65536 - max 65536 rows, 65536 cols
Eternal ID of this version: #1026148/5
Text MD5: 88fb97961ccecb2d19efcf392f79e2c1
Transpilation MD5: fe06537f8b44d7f8bba269d1664b655c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-27 03:20:14
Source code size: 609 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 214 / 620
Version history: 4 change(s)
Referenced in: [show references]