Libraryless. Click here for Pure Java version (7632L/44K).
1 | svoid test_QuadTreeBitMatrix() { |
2 | // 4*4, one pixel white |
3 | BitSetMatrix m = new(4, 4); |
4 | m.set(1, 1); |
5 | QuadTreeBitMatrix qt = bitMatrixToQuadTree(m); |
6 | assertTrueVerbose(equal := eqMatrices(m, qt)); |
7 | assertEqualsVerbose(2, qt.compositeNodeCount()); |
8 | |
9 | // turn pixel back to black |
10 | qt.set(1, 1, false); |
11 | m.set(1, 1, false); |
12 | assertTrueVerbose(equal := eqMatrices(m, qt)); |
13 | print(structure(qt)); |
14 | qt.set(1, 1, false); |
15 | print(structure(qt)); |
16 | assertEqualsVerbose(0, qt.compositeNodeCount()); |
17 | |
18 | // all pixels white |
19 | for y to 4: |
20 | for x to 4: |
21 | qt.set(x, y); |
22 | assertEqualsVerbose(0, qt.compositeNodeCount()); |
23 | |
24 | test_QuadTreeBitMatrix_2(); |
25 | } |
26 | |
27 | svoid test_QuadTreeBitMatrix_2() { |
28 | for (double p = .1; p < 1; p += .1) { |
29 | new Average nodes; |
30 | repeat 100 { |
31 | var matrix = randomBitMatrix(8, 8, p); |
32 | QuadTreeBitMatrix qt = bitMatrixToQuadTree(matrix); |
33 | nodes.add(qt.compositeNodeCount()); |
34 | assertTrue(eqMatrices(matrix, qt)); |
35 | } |
36 | printVars(+p, +nodes); |
37 | } |
38 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033652 |
Snippet name: | test_QuadTreeBitMatrix |
Eternal ID of this version: | #1033652/5 |
Text MD5: | 69ae3819f076799022dac51235502194 |
Transpilation MD5: | 61d9f0eec896741c6de41c869297f13f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-12-26 16:47:15 |
Source code size: | 1041 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 144 / 243 |
Version history: | 4 change(s) |
Referenced in: | [show references] |