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

26
LINES

< > BotCompany Repo | #1026150 // SparseIntArray2D_65536_v2 - max 65536 rows, 65536 cols, even faster (probably not much though)

JavaX fragment (include)

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

Author comment

Began life as a copy of #1026148

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: #1026150
Snippet name: SparseIntArray2D_65536_v2 - max 65536 rows, 65536 cols, even faster (probably not much though)
Eternal ID of this version: #1026150/4
Text MD5: 33ec5e5658adda84b1e618d468cede5d
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:24:57
Source code size: 576 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 144 / 440
Version history: 3 change(s)
Referenced in: [show references]