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

23
LINES

< > BotCompany Repo | #1033128 // SubMatrix - virtual clip of a matrix

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

Libraryless. Click here for Pure Java version (4042L/23K).

1  
persistable sclass SubMatrix<A> extends AbstractMatrix<A> {
2  
  Matrix<A> matrix;
3  
  int x1, y1;
4  
5  
  *(Matrix<A> *matrix, Rect r) {
6  
    super(r.w, r.h);
7  
    x1 = r.x; y1 = r.y;
8  
  }
9  
10  
  // currently no range checks
11  
  
12  
  public A get(int x, int y) {
13  
    try {
14  
      ret matrix.get(x+x1, y+y1);
15  
    } catch e {
16  
      throw augmentException(e, this);
17  
    }
18  
  }
19  
  
20  
  public void set(int x, int y, A a) { matrix.set(x+x1, y+y1, a); }
21  
  
22  
  toString { ret renderFunctionCall("SubMatrix", x1, y1, w, h); }
23  
}

Author comment

Began life as a copy of #1033127

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033128
Snippet name: SubMatrix - virtual clip of a matrix
Eternal ID of this version: #1033128/5
Text MD5: fcc26049dfe3830f2f0545d8fc49ae0f
Transpilation MD5: 6f481d712aad0ac7e6bdd4e4fe324951
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 17:16:01
Source code size: 515 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 145 / 251
Version history: 4 change(s)
Referenced in: [show references]