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).

persistable sclass SubMatrix<A> extends AbstractMatrix<A> {
  Matrix<A> matrix;
  int x1, y1;

  *(Matrix<A> *matrix, Rect r) {
    super(r.w, r.h);
    x1 = r.x; y1 = r.y;
  }

  // currently no range checks
  
  public A get(int x, int y) {
    try {
      ret matrix.get(x+x1, y+y1);
    } catch e {
      throw augmentException(e, this);
    }
  }
  
  public void set(int x, int y, A a) { matrix.set(x+x1, y+y1, a); }
  
  toString { ret renderFunctionCall("SubMatrix", x1, y1, w, h); }
}

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: 143 / 248
Version history: 4 change(s)
Referenced in: [show references]