Libraryless. Click here for Pure Java version (3241L/18K).
1 | // a scheduler isn't actually referenced, but might be |
2 | // (e.g. for collection stats) |
3 | sclass PMapCollector<A, B> /*extends Probabilistic*/ {
|
4 | new Map<A, B> map; |
5 | new L<IVF2<A, B>> onNewEntry; |
6 | new L<IVF3<A, B, B>> onChangedEntry; |
7 | |
8 | *() {}
|
9 | *(Map<A, B> *map) {}
|
10 | |
11 | void put(A key, B value) {
|
12 | bool isNew = !map.containsKey(key); |
13 | B oldValue = null; |
14 | bool isChanged = !isNew && !eq(oldValue = map.get(key), value); |
15 | if (isNew || isChanged) |
16 | map.put(key, value); |
17 | if (isNew) |
18 | pcallFAll(onNewEntry, key, value); |
19 | else |
20 | pcallFAll(onChangedEntry, key, oldValue, value); |
21 | } |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
| Snippet ID: | #1032183 |
| Snippet name: | PMapCollector - probabilistic map collector (collects key-value pairs during a probabilistic computation) |
| Eternal ID of this version: | #1032183/6 |
| Text MD5: | 98f017f84d9b18ae6767d4e561358052 |
| Transpilation MD5: | 6fde69a44bcc1eebb4e688c988b2fbce |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-08-17 19:52:35 |
| Source code size: | 632 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 418 / 615 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |