Libraryless. Click here for Pure Java version (2241L/14K).
1 | final sclass SparseIntArray2D implements IIntArray2D { |
2 | int nrows, ncols; |
3 | new HashMap<Pt, Int> entries; |
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 or0(entries.get(Pt(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(Pt(i, j)); |
20 | else |
21 | entries.put(Pt(i, j), x); |
22 | ret x; |
23 | } |
24 | } |
Began life as a copy of #1026139
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: | #1026140 |
Snippet name: | SparseIntArray2D |
Eternal ID of this version: | #1026140/5 |
Text MD5: | 30095902ee746da7e3a570616eb2027a |
Transpilation MD5: | d1f98b210bbb67aef713775303c379ee |
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:01:10 |
Source code size: | 516 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 222 / 583 |
Version history: | 4 change(s) |
Referenced in: | [show references] |