Libraryless. Click here for Pure Java version (2252L/14K).
sclass AllOnAllWithUpdates<A, B> { long aCounter, bCounter; new TreeMap<Long, A> aList; new TreeMap<Long, B> bList; LPair<LongRange> todo = new LinkedList; LPair<Long> todo2 = new LinkedList; synchronized void newA(A a) { long c = aCounter++; aList.put(c, a); addPair(todo, longRange_one(c), longRange(0, bCounter)); } synchronized void newB(B b) { long c = bCounter++; bList.put(c, b); addPair(todo, longRange(0, aCounter), longRange_one(c)); } synchronized void updateA(A a) { removeValue(aList, a); newA(a); } synchronized void updateB(B b) { removeValue(bList, b); newB(b); } synchronized Pair<A, B> next() { while licensed { while (empty(todo2)) { if (empty(todo)) null; Pair<LongRange> p = popFirst(todo); addAll(todo2, outerProduct_pairs(keys(subMap_longRange(aList, p.a)), keys(subMap_longRange(bList, p.b)))); } Pair<Long> p = popFirst(todo2); A a = aList.get(p.a); B b = bList.get(p.b); if (a != null && b != null) ret pair(a, b); } null; } }
Began life as a copy of #1023892
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023903 |
Snippet name: | AllOnAllWithUpdates |
Eternal ID of this version: | #1023903/11 |
Text MD5: | 5028f2ad8136bc9ab2c6bebd93e563df |
Transpilation MD5: | 86c2340fd59852984527276e79ee2566 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-07-12 02:19:36 |
Source code size: | 1150 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 278 / 737 |
Version history: | 10 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |