Libraryless. Click here for Pure Java version (3198L/20K).
sclass AllOnAll<A, B> implements Producer<Pair<A, B>> { new L<A> aList; new L<B> bList; LPair<IntRange> todo = new LinkedList; LPair<A, B> todo2 = new LinkedList; void addA(A a) { newA(a); } void addAIfNotNull(A a) { if (a != null) newA(a); } synchronized void newA(A a) { add(aList, a); addPair(todo, intRange_last(aList), intRange(0, l(bList))); } synchronized void newAs(Iterable<A> l) { fOr (A a : l) newA(a); } void addB(B b) { newB(b); } void addBIfNotNull(B b) { if (b != null) newB(b); } synchronized void newB(B b) { add(bList, b); addPair(todo, intRange(0, l(aList)), intRange_last(bList)); } synchronized void newBs(Iterable<B> l) { fOr (B b : l) newB(b); } public synchronized Pair<A, B> next() { while (empty(todo2)) { if (empty(todo)) null; Pair<IntRange> p = popFirst(todo); addAll(todo2, outerProduct_pairs(subList(aList, p.a), subList(bList, p.b))); } ret popFirst(todo2); } synchronized L cloneBList() { ret clonedList(bList); } L<A> getAs() { ret aList; } L<B> getBs() { ret bList; } }
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: | #1023892 |
Snippet name: | AllOnAll |
Eternal ID of this version: | #1023892/17 |
Text MD5: | b294e321494f56ff4c717f18587745be |
Transpilation MD5: | 5590e5cf40969241cb47f270bca9e1ef |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-06-20 20:09:36 |
Source code size: | 1176 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 456 / 965 |
Version history: | 16 change(s) |
Referenced in: | #1023903 - AllOnAllWithUpdates #1027757 - AllOnAllOperation #1028466 - AllOnAll_probabilistic [works] #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |