Libraryless. Click here for Pure Java version (53L/1K).
1 | static <A> L<A> matrixToList(Matrix<A> m) { |
2 | if (m == null) null; |
3 | int w = m.getWidth(), h = m.getHeight(), n = w*h; |
4 | |
5 | ret new RandomAccessAbstractList<A>() { |
6 | public int size() { ret n; } |
7 | |
8 | public A get(int i) { |
9 | ret m.get(i % w, i / w); |
10 | } |
11 | |
12 | public A set(int i, A val) { |
13 | A old = m.get(i % w, i % h); |
14 | m.set(i % w, i / w, val); |
15 | ret old; |
16 | } |
17 | }; |
18 | } |
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: | 193 / 281 |
Version history: | 1 change(s) |
Referenced in: | [show references] |