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)

final sclass SparseIntArray2D_65536_v2 extends IntIntMap implements IIntArray2D {
  int nrows, ncols;
  
  *(int *nrows, int *ncols) { super(256, 0.75f); }
  
  public int nrows() { ret nrows; }
  public int ncols() { ret ncols; }

  /** Returns A(i, j). */
  public int get(int i, int j) {
    ret get(combine(i, j));
  }

  /** Sets A(i, j). */
  public int set(int i, int j, int x) {
    if (x == 0)
      remove(combine(i, j));
    else
      put(combine(i, j), x);
    ret x;
  }
  
  static int combine(int i, int j) {
    ret i << 16 | j;
  }
}

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: 204 / 505
Version history: 3 change(s)
Referenced in: [show references]