Libraryless. Click here for Pure Java version (53L/1K).
static <A> L<A> matrixToList(Matrix<A> m) { if (m == null) null; int w = m.getWidth(), h = m.getHeight(), n = w*h; ret new RandomAccessAbstractList<A>() { public int size() { ret n; } public A get(int i) { ret m.get(i % w, i / w); } public A set(int i, A val) { A old = m.get(i % w, i % h); m.set(i % w, i / w, val); ret old; } }; }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1033132 |
| Snippet name: | matrixToList |
| Eternal ID of this version: | #1033132/2 |
| Text MD5: | 78cfec5436f852743ba9ffeebce42591 |
| Transpilation MD5: | aef22ecfa1b89ff27fa8b9e7e40ef689 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-10-15 16:48:08 |
| Source code size: | 414 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 415 / 558 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |