Libraryless. Click here for Pure Java version (2521L/16K).
1 | // is allowed to return null when result is empty |
2 | static int[] intersectSortedIntArrays_ofs(int[] a, int[] b, int ofs) { |
3 | int i = 0, j = 0, la = l(a), lb = l(b); |
4 | if (la == 0 || lb == 0) null; |
5 | IntBuffer buf = new(min(la, lb)); |
6 | while (i < la && j < lb) { |
7 | int x = a[i], y = b[j]+ofs; |
8 | if (x == y) { |
9 | buf.add(x); |
10 | ++i; |
11 | ++j; |
12 | } else if (x < y) |
13 | ++i; |
14 | else |
15 | ++j; |
16 | } |
17 | ret buf.toArray(); |
18 | } |
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: | 228 / 333 |
Version history: | 4 change(s) |
Referenced in: | [show references] |