Libraryless. Click here for Pure Java version (5388L/30K).
1 | static IntBuffer intArrayToNonZeroTable(int[] array) { |
2 | // some reasonable compromise for initial size |
3 | IntBuffer buf = new(array.length); |
4 | |
5 | for i over array: { |
6 | int value = array[i]; |
7 | if (value != 0) { |
8 | buf.add(i); |
9 | buf.add(value); |
10 | } |
11 | } |
12 | |
13 | ret buf; |
14 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035044 |
Snippet name: | intArrayToNonZeroTable - gives an IntBuffer of index, value, index, value, ... for all non-zero elements of the array |
Eternal ID of this version: | #1035044/2 |
Text MD5: | 5fa467f91ef18c4ddcf7c813875f6913 |
Transpilation MD5: | 64199f9a50362ebb83b2acd6374aaff0 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-25 21:21:51 |
Source code size: | 292 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 117 / 176 |
Version history: | 1 change(s) |
Referenced in: | [show references] |