Uses 11335K of libraries. Click here for Pure Java version (2233L/14K).
1 | !include once #1027304 // eclipse collections |
2 | |
3 | import org.eclipse.collections.impl.map.mutable.primitive.*; |
4 | |
5 | static IBWImage lazyBWImage(int w, int h, IF2<Int, Int, Float> getFloatPixel) { |
6 | ret new IBWImage { |
7 | new IntFloatHashMap knownPixels; |
8 | |
9 | public int getWidth() { ret w; } |
10 | public int getHeight() { ret h; } |
11 | |
12 | public float getFloatPixel(int x, int y) { |
13 | int i = x*w+h; |
14 | Float f = knownPixels.getIfAbsent(i, Float.NaN); |
15 | if (!isNaN(f)) ret f; |
16 | knownPixels.put(i, f = getFloatPixel.get(x, y)); |
17 | ret f; |
18 | } |
19 | }; |
20 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027305 |
Snippet name: | lazyBWImage - IBWImage with on-demand pixel generation. not synchronized |
Eternal ID of this version: | #1027305/5 |
Text MD5: | 505c40580f962c808d2fdb71ecd665d0 |
Transpilation MD5: | 933e7b29940f6115c3ccedbf2279fcfc |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-01 11:26:31 |
Source code size: | 584 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 202 / 310 |
Version history: | 4 change(s) |
Referenced in: | [show references] |