Libraryless. Click here for Pure Java version (7632L/44K).
svoid test_QuadTreeBitMatrix() { // 4*4, one pixel white BitSetMatrix m = new(4, 4); m.set(1, 1); QuadTreeBitMatrix qt = bitMatrixToQuadTree(m); assertTrueVerbose(equal := eqMatrices(m, qt)); assertEqualsVerbose(2, qt.compositeNodeCount()); // turn pixel back to black qt.set(1, 1, false); m.set(1, 1, false); assertTrueVerbose(equal := eqMatrices(m, qt)); print(structure(qt)); qt.set(1, 1, false); print(structure(qt)); assertEqualsVerbose(0, qt.compositeNodeCount()); // all pixels white for y to 4: for x to 4: qt.set(x, y); assertEqualsVerbose(0, qt.compositeNodeCount()); test_QuadTreeBitMatrix_2(); } svoid test_QuadTreeBitMatrix_2() { for (double p = .1; p < 1; p += .1) { new Average nodes; repeat 100 { var matrix = randomBitMatrix(8, 8, p); QuadTreeBitMatrix qt = bitMatrixToQuadTree(matrix); nodes.add(qt.compositeNodeCount()); assertTrue(eqMatrices(matrix, qt)); } printVars(+p, +nodes); } }
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: | 354 / 509 |
| Version history: | 4 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |