Libraryless. Click here for Pure Java version (302L/2K).
static int[] subArray(int[] b, int start, int end) { int[] x = new int[end-start]; System.arraycopy(b, start, x, 0, end-start); ret x; } meta-for byte also as long { static byte[] subArray(byte[] b, int start, int end) { start = max(start, 0); end = min(end, l(b)); if (start >= end) ret new byte[0]; byte[] x = new byte[end-start]; System.arraycopy(b, start, x, 0, end-start); ret x; } } static short[] subArray(short[] b, int start, int end) { if (start <= 0 && end >= l(b)) ret b; short[] x = new short[end-start]; System.arraycopy(b, start, x, 0, end-start); ret x; } static float[] subArray(float[] b, int start, int end) { float[] x = new float[end-start]; System.arraycopy(b, start, x, 0, end-start); ret x; } static O[] subArray(O[] b, int start) { ret subArray(b, start, l(b)); } static O[] subArray(O[] b, int start, int end) { start = max(start, 0); end = min(end, l(b)); if (start >= end) ret new O[0]; O[] x = new O[end-start]; System.arraycopy(b, start, x, 0, end-start); ret x; }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003152 |
Snippet name: | subArray - return part of an array. TODO: optimize (see subByteArray) |
Eternal ID of this version: | #1003152/8 |
Text MD5: | bc830b7a106e1a97b2c0b783ad9f7d4b |
Transpilation MD5: | 11ef333bcd23bbaacf80f18a85ca6f1a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-28 19:37:50 |
Source code size: | 1094 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 788 / 823 |
Version history: | 7 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |