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

19
LINES

< > BotCompany Repo | #1033661 // IntArrayBitMatrix - simple int array-based implementation of BitMatrix

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

Libraryless. Click here for Pure Java version (5557L/30K).

1  
persistable sclass IntArrayBitMatrix extends AbstractMatrix<Bool> is BitMatrix {
2  
  int[] data;
3  
  
4  
  *(int *w, int *h) { data = new int[arrayLength()]; }
5  
  *(int *w, int *h, int[] *data) {}
6  
  
7  
  int arrayLength() { ret (w*h+31)/32; }
8  
  static int arrayLength(int w, int h) { ret (w*h+31)/32; }
9  
10  
  public Bool get(int x, int y) {
11  
    try {
12  
      ret getBitFromIntArray_littleEndian(data, y*w+x);
13  
    } catch e {
14  
      fail(e, "Access out of bounds", +x, +y, +w, +h);
15  
    }
16  
  }
17  
  
18  
  public void set(int x, int y, Bool a default true) { setBitInIntArray_littleEndian(data, y*w+x, a); }
19  
}

Author comment

Began life as a copy of #1033581

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033661
Snippet name: IntArrayBitMatrix - simple int array-based implementation of BitMatrix
Eternal ID of this version: #1033661/5
Text MD5: 73f99e5a2b91abe5e06e828ff942d4b5
Transpilation MD5: b13ab7b69fdfca594bd7ddfd0d4bd608
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-06 23:15:26
Source code size: 601 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 74 / 154
Version history: 4 change(s)
Referenced in: [show references]