Libraryless. Click here for Pure Java version (2521L/16K).
// is allowed to return null when result is empty static int[] intersectSortedIntArrays_ofs(int[] a, int[] b, int ofs) { int i = 0, j = 0, la = l(a), lb = l(b); if (la == 0 || lb == 0) null; IntBuffer buf = new(min(la, lb)); while (i < la && j < lb) { int x = a[i], y = b[j]+ofs; if (x == y) { buf.add(x); ++i; ++j; } else if (x < y) ++i; else ++j; } ret buf.toArray(); }
Began life as a copy of #1029026
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: | #1029029 |
Snippet name: | intersectSortedIntArrays_ofs [add offset to second list] |
Eternal ID of this version: | #1029029/5 |
Text MD5: | 0a2104065ffa7ccf376df18aa852a768 |
Transpilation MD5: | 9c5605d5bc5fdb1e6ba1c5f21587b622 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-17 01:31:44 |
Source code size: | 446 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 229 / 334 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1029030 - intersectSortedIntArrays_ofs_optimized |